Skip to content
Advertisement

Tag: group-by

SQL Date range by month returns in multiple rows

I am looking to get the count of entries by the month. However, this is returning the total count. I would like it to be something like. Month —– Count January —- 500 February —- 600 If I can’t get the month in there, thats fine, but I would definitely like to have it so the count has its own

Compare two values in a row

select event_slots.id as event_slot_id, u.first_name, u.id AS user_id, sum(case when next_round = 1 then 1 else 0 end) AS yes, sum(case when next_round = 2 then 1 else 0 end) AS no from event_slots …

mysql get result from join table

I have a tables person and exam. I want to show data where all exam is PASS, show the latest exam pass_date. like table below what query to get it? please help. thanks! Answer You can use aggregation and conditional expressions: Note that for this sample data, you don’t need to bring in the person table to get the results

Advertisement