Monday 15 June 2015

subquery - how to run MySQL sub queries to count the records. -


I have tables that are ordered sequence tables

  GroupA (id, and some group b (ID, Group A_ID, some fields) Group B (ID, Group B_ID, some fields)   

Group A has A1, which is Group B to B1, B2, B 3 and each group is near B. Some groups in each. Now I want to get this information in the same query.

  group | total_ group B | total_ group S1 | 4 | 10 A2 | 6 | 1 2   

I try some sub-questions, but all give error because my argument is not correct if this is possible then how to do it I can solve it with many questions I want to be a single one, my partial duplicate of some SO queries.

Whatever you think of your question, you need something like the following

  SELECT a.id, count (distinct b.id) Total_GroupB, count (different c.id) Gr Oup_A from Total_GroupC on a left JOINGroupB B a.id = b.groupa_id LEFT JOIN GROUPC c ON b.id = c Groupb_id GROUP by a.id    

No comments:

Post a Comment