williambhowardjr
asked on
SQL Query using Group
What is the needed Query statement to find the total number of orders per person
Given:
Table A:
ID OrderNumber
___________________
1 X123
2 X213
1 X345
2 x237
3 x554
4 x435
1 x333
Table B:
ID FName Lname
_____________________
1 Jon Smith
3 Al Berry
2 Sue Jones
4 Jack Jill
Result Table:
Name Count
_____________________
Jon Smith 3
Sue Jones 2
Al Berry 1
Jack Jill 1
Given:
Table A:
ID OrderNumber
___________________
1 X123
2 X213
1 X345
2 x237
3 x554
4 x435
1 x333
Table B:
ID FName Lname
_____________________
1 Jon Smith
3 Al Berry
2 Sue Jones
4 Jack Jill
Result Table:
Name Count
_____________________
Jon Smith 3
Sue Jones 2
Al Berry 1
Jack Jill 1
or:
select b.FName + ' ' + b.Lname as FullName, count(*) as Count_of
from table_b as b
inner join table_a as a on b.id = a.id
group by b.FName + ' ' + b.Lname
select b.FName + ' ' + b.Lname as FullName, count(*) as Count_of
from table_b as b
inner join table_a as a on b.id = a.id
group by b.FName + ' ' + b.Lname
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Works Great - Thanks for the Help.
from table_b as b
inner join table_a as a on b.id = a.id
group by b.FName , b.Lname