[Solved] SQL and Counting

[ad_1] Give this a try: select name, count(case when grade in (‘A’, ‘B’, ‘C’) then 1 end) totalPass, count(case when grade=”A” then 1 end) totalA, count(case when grade=”B” then 1 end) totalB, count(case when grade=”C” then 1 end) totalC from t group by name Here is the fiddle. Or we can make it even simpler … Read more

[Solved] Joins and/or Sub queries or Ranking functions

[ad_1] Using max(ship_num) is a good idea, but you should use the analytic version (with an OVER clause). select * from ( select t.*, max(ship_num) over (partition by order_id) as orders_max_ship_num from table1 t1 ) with_max where ship_num = orders_max_ship_num order by order_id, item_code; 0 [ad_2] solved Joins and/or Sub queries or Ranking functions