SQL Sever: sum col in one table based on values in another
How can i Sum values in one table only if they exist in another.
eg table1 - typeOfBiscuits
biscuits
jaffacakes
digestives
table2 - inventry
type number
digestives 2
digestives 3
jaffacakes 2
digestives 3
jaffacakes 4
cheesecake 1
Desired result of select Count(number) from Inventry where type = <not
sure how to get type from typeOfBisuit table>
type count
digestives 8
jaffacakes 6
My attempt is as follows but i get a 'reference to multi part string' error
select Count(number) from Inventry where type = typeOfBiscuits.type
No comments:
Post a Comment