mysql - counting of rows with group by -
seat_num service_key source_id destination_id 1 19229 0 60 1 19229 240 600 2 19229 0 240 3 19229 0 600
my table data above. want result below
count service_key source_id destination_id 3 19229 0 60 2 19229 240 600 2 19229 0 240 3 19229 0 600
the logic behind count of seat nums should fall between range of source , destination. issue here 0 600 source , destination counting 4 should 3 because same seat num (1) used twice. please let me know how result required.
try :
select service_key,source_id,destination_id,count(seat_num) tablename seat_num between source_id , destination_id group seat_num having count(seat_num) > 0;
Comments
Post a Comment