SQLTeam.com | Weblogs | Forums

Multiple group by clause

Is it possible to use multiple group by in a single SQL statement. Have a product details table with color and size column. Want to get distinct
list of colour and size in a single SQL statement
Select colour from products group by colour
Select size from products group by size

Thank you in advance

please provide sample data?

If you want distinct values - why are you using a GROUP BY?

Your question doesn't make sense...do you want all combinations of colour/size - or just a list of available colours and sizes?

If you want the distinct combinations of colour and size, then do this:

SELECT DISTINCT colour, size FROM products

If you want one result set with both the distinct colours and the distinct sizes, do this:

SELECT DISTINCT colour AS colour_or_size FROM products