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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT * but without the duplicated values... 1

Status
Not open for further replies.

sugarferret

IS-IT--Management
Jul 11, 2005
33
US
hi, i have duplicated values in the first column like this:

SKU,REVENUE
----------
a002,20
a002,35
b017,1
b017,14

This is the SQL code which generates that table:

Code:
SELECT SKU, REVENUE = sum(ShippedSubtotal)
FROM OrderDetails
WHERE ShippedSubtotal > 0;[code]


My question is little bit challenging (for me)...

How can i edit the sql code in order to display the SKU values with no duplicated and the sum of Revenue for those duplicated SKU, see this table, this is what i need:

			SKU,REVENUE
			----------
-->No duplicated sku's	a002,55		<--and with the sum of revenue
			b017,15   

does it made sense... can help me please?
any help or advicing will be appreciated.
thanks in advance.

Aldo
 
try this:

SELECT SKU, sum(ShippedSubtotal)
FROM OrderDetails
GROUP BY SKU

-DNG
 
Great!!! your imput help to get it!!

SELECT SKU, Sum(ShippedSubtotal)
FROM [Order Details]
GROUP BY SKU
ORDER BY SKU;


Thanks DotNetGnat!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top