Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase ««12

Exclude rows Expand / Collapse
Posted Friday, September 13, 2013 7:54 AM



Group: General Forum Members
Last Login: Today @ 10:14 AM
Points: 16,137, Visits: 16,838
lanky_doodle (9/13/2013)
[b]Alan.B (9/12/2013)If I understand the original OP correctly (" If something has been credited, the billed item row should be excluded") this would not provide the right answer with this sample data:

I believe the right answer would be 8, your query would return a 5.

... but who knows without any ddl

The billed item row and the credit row should both be excluded. So say there was only 2 rows, both for the same case, one row had 2 hours billed and the other row 2 hours credited, the result should be 0.

In otherwords, if something has been credited, the results should show as if it was never billed in the first place. We're trying to work out sales money, so if someone bills £200 and then credits it all back, they've really not billed (gained) anything.

Then my solution should work just fine?


Need help? Help us help you.

Read the article at for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1494584
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse