Hi all,
I have this table
sales ( product_id Serial Not Null,
price Numeric Not Null,
product_code Char(3) Not Null);
sales (product_id,price, product);
I want to write a query that return the products that sold with the highest volume, for example:
product_id _|_ Volume
1 | 1400
I did this:
Select Max(temp.volume)
From (Select S.product_id, Count (*) As volume
From Sales S
Group By S.product_id) As temp;
But this only gives me the highest volume without the product_id.
The query :
Select S.product_id, Count (*) As volume
From Sales S
Group By S.product_id;
gives me the product_id, and the total volume of each product shorted by product_id but not SINGLE ENTRY of a product and its volume. It gives me this:
product_id _|_ Volume
1 | 890
2 | 1400
3 | 1100
How do i get both the product_id and its volume for one with hightest volume sold?
Please Help!
Whate.
I have this table
sales ( product_id Serial Not Null,
price Numeric Not Null,
product_code Char(3) Not Null);
sales (product_id,price, product);
I want to write a query that return the products that sold with the highest volume, for example:
product_id _|_ Volume
1 | 1400
I did this:
Select Max(temp.volume)
From (Select S.product_id, Count (*) As volume
From Sales S
Group By S.product_id) As temp;
But this only gives me the highest volume without the product_id.
The query :
Select S.product_id, Count (*) As volume
From Sales S
Group By S.product_id;
gives me the product_id, and the total volume of each product shorted by product_id but not SINGLE ENTRY of a product and its volume. It gives me this:
product_id _|_ Volume
1 | 890
2 | 1400
3 | 1100
How do i get both the product_id and its volume for one with hightest volume sold?
Please Help!
Whate.