Help with sum

Last Post 19 Mar 2012 02:19 AM by venkanna. 2 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
JASBRYDEN
New Member
New Member

--
29 Feb 2012 01:11 PM
I have a table Customerno CLass Ordertype 854785 2 C 857854 5 C 852368 21 C 852368 21 C 857542 85 C I want a script to give me the customerno and class and a total of credits (C) e.g. customerno class credit 852368 21 2 857542 85 1 Note that Ordertype is a nvarchar So SUM does not work, please help !!!!!!
Vishal Gajjar
New Member
New Member

--
29 Feb 2012 07:14 PM
I think you need a count here not sum: try this: SELECT Customerno, Class, Count(Ordertype) FROM <> WHERE Ordertype = N'C' GROUP BY Customerno, Class
venkanna
New Member
New Member

--
19 Mar 2012 02:19 AM
Hi you can use below query as well ,even i feel that is not sum it could be could

select distinct customer.Customerno,customer.CLass,
count(customer.Ordertype) over(PARTITION BY CUSTOMERNO ) as total
from customer


Acceptable Use Policy
---