Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count Query multiple columns. 1

Status
Not open for further replies.

Kamrock

Technical User
Mar 10, 2006
2
GB
Ok, I've searched around the forum and I can't find what I'm looking for. If anyone can help me with the Count query pulling up multiple readouts. Imagine I have a table describing the quantity of items, where each item has a unique number, a descriptive number and a boolean value explaining it's visibility, example:

TableQuantity
Unique(auto) | Item | Visible
1 | 0 | Yes
2 | 0 | Yes
3 | 1 | Yes
4 | 0 | No

Any ideas on how to effectively 'Count' the unique ID with relation to both the visible flag and the item number to return a result similar to

Item | Quantity(visible)
0 | 2
1 | 1

Ady 'Kamrock' Durn
 
Something like this ?
SELECT Item, COUNT(*) Quantity
FROM yourTable
WHERE Visible=True
GROUP BY Item

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Ahh, yes, I was missing the GROUP BY , I'll give it a go, thanks...

Ady 'Kamrock' Durn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top