Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
cidr
Posting Yak Master
207 Posts |
Posted - 2010-08-25 : 05:01:59
|
Hi there,I'd like to sum only the first row of each category of the grouping. This is because there are duplicates in the database i.e.Contractor Amt InvoiceNo AwaitingValidationABCfixers 200 1 4 ABCfixers 100 2 4 ABCfixers 150 3 4123Diggers 50 1a 12123Diggers 100 2b 12123Diggers 455 3b 12 123Diggers 120 4b 12 There's only 4 invoices awaiting validation for ABCfixers and 12 for 123Diggers. In SSRS, If I sum this for the Contractor group I'll get 16 for ABCfixers and 48 for 123Diggers.I want to know if I can take the first row of each 'Contractor' and sum that only within ssrsIs there a way to do this?Many thanks |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-08-25 : 05:41:20
|
It will be easier to help if you can give wanted output in relation to sample data... No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
cidr
Posting Yak Master
207 Posts |
Posted - 2010-08-25 : 06:16:36
|
Thanks for replying. At first I was doing a join with the contractor tables and the table with validation dates, via contractorID. This is what's giving me the dupliates. I was going to sort this out via SSRSInstead, I've done Union all to pull the data I need to show in the grouping and filtered out these rows in SSRS I appreciate the request for output data but the work around will do for now.Cheers |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-08-25 : 10:09:01
|
quote: Originally posted by cidr Hi there,I'd like to sum only the first row of each category of the grouping. This is because there are duplicates in the database i.e.Contractor Amt InvoiceNo AwaitingValidationABCfixers 200 1 4 ABCfixers 100 2 4 ABCfixers 150 3 4123Diggers 50 1a 12123Diggers 100 2b 12123Diggers 455 3b 12 123Diggers 120 4b 12 There's only 4 invoices awaiting validation for ABCfixers and 12 for 123Diggers. In SSRS, If I sum this for the Contractor group I'll get 16 for ABCfixers and 48 for 123Diggers.I want to know if I can take the first row of each 'Contractor' and sum that only within ssrsIs there a way to do this?Many thanks
add a rownumber for group and put rowno=1 in condition inside sum like=Sum(IIF (Fields!RowNumber.value=1,Fields!Amt.value ,0))------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
cidr
Posting Yak Master
207 Posts |
Posted - 2010-08-31 : 10:48:55
|
Oh yeah visakh16, I could have done that way after all! cheers folks |
|
|
|
|
|