If I have the following table in a database:
ROW1 ROW2 ROW3
1 a x
2 b y
3 c z
4 a x
5 b c
6 a g
and want to perform a select querie where the querie returns the total number of rows where a value exists:
So, the return would be:
Name (From row 2) Count of times value is in Row2
a 3
b 2
c 1
How would I do this?
I have tried a count, sum, etc but cannot figure out how to select everything from row2 and then categorize the values and count them at the same time.
Any help with this will be appreciated.
Also - can anyone give me the name of a book that I can buy that I can use as both a GOOD reference and teach myself SQL at the same time. The 'Teach yourself in x days' didnt seem to be enough information.
Thanks -
Bob
ROW1 ROW2 ROW3
1 a x
2 b y
3 c z
4 a x
5 b c
6 a g
and want to perform a select querie where the querie returns the total number of rows where a value exists:
So, the return would be:
Name (From row 2) Count of times value is in Row2
a 3
b 2
c 1
How would I do this?
I have tried a count, sum, etc but cannot figure out how to select everything from row2 and then categorize the values and count them at the same time.
Any help with this will be appreciated.
Also - can anyone give me the name of a book that I can buy that I can use as both a GOOD reference and teach myself SQL at the same time. The 'Teach yourself in x days' didnt seem to be enough information.
Thanks -
Bob