Hello,
I need help with the syntax of a query, and this is the simplefyed version of the problem:
let's say I have a database with sales information . I'm selling differen items, each one in three colors. Each record on the database represents one sale , and contains this information: ItemId and Color. The Color field can contain "red", "blue" or "green". What I need to get is a list of all items sold, with the number of red models, blue models and green models sold for each item. If I wanted to know how many red models where sold from each item, I would use:
But how do I get three different counts for each item, every count with it's color condition?
Hope this was clear, and thanks in advance!
Yael
I need help with the syntax of a query, and this is the simplefyed version of the problem:
let's say I have a database with sales information . I'm selling differen items, each one in three colors. Each record on the database represents one sale , and contains this information: ItemId and Color. The Color field can contain "red", "blue" or "green". What I need to get is a list of all items sold, with the number of red models, blue models and green models sold for each item. If I wanted to know how many red models where sold from each item, I would use:
Code:
select itemID, count(color)
where color="red"
group by itemId
But how do I get three different counts for each item, every count with it's color condition?
Hope this was clear, and thanks in advance!
Yael