Chrissy321 (8/2/2012)
I'm fascinated.....I am working with Lynn's code.Say I wanted certain clients those whose ClientID was < than 3.
Clearly I can add any conditions to the final SELECT statement but performance would suffer if I had a multitude of clients.
Can I filter on the CTE?
I tried the following but did not get the expected results.
WHERE
(s1.ClientID IS NULL OR s1.ClientID < 3)
OR
(s2.ClientID IS NULL OR s2.ClientID < 3)
I appreciate the input. Obviously these are not real tables and data, just an abstraction of my real problem. Sometimes I over simplify things and don't anticipate all my needs. Bust since I am not exposing real data or data structure I get to keep my job! 😀
I am also wondering if I should solve each problem (new and lost) separately and union the results...
Lynn took my code and wrapped it so that Jan 2012 would not have 3 "New" clients and Jun 2012 would not have every client "Lost" i was able to fix my code before lynn posted his reply.
i am currently working on a test bed as i do believe my code will be more performant as i only have the single select but as i may get busy at work it may wait till monday.
For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw[/url]
Need to Split some strings? Jeff Moden's DelimitedSplit8K[/url]
Jeff Moden's Cross tab and Pivots Part 1[/url]
Jeff Moden's Cross tab and Pivots Part 2[/url]