|
I have 2 tables: MailFile and Responder. Need a report that shows the following:
Qty Mailed will be a count where country = Greece for 1st row, Malaysia for 2nd row and Singapore for 3rd row from mailfile table. Active and Inactive will be a count of each in the responder table where couponcode matches in both tables. Non-responder will be where there is NO Match in the 2 tables. Did not know whether a PIVOT command would work in SQL or not.
(comments are locked)
|
|
I am not 100% sure I understand your question but here is an attempt at a solution (it does not use PIVOT and has some assumptions about your column types)... I believe you are looking for each country, along with a total number of codes, total number of active codes, total number of inactive codes, and total number of unknown codes that you are referring too as non-responders. Note that this code was tested on SQL 2008. I do not see any reason why it would not be backwards compatible with SQL 2005. You are the man. I edited the entry a little to use a couple of case statements b/c active and inactive were data entries in the responsetype column. Once I did this, it worked perfectly. Thank you!
May 08 '10 at 11:01 AM
Tom Redd
+1 for the very nicely formatted and easy to read commented code with test tables and data. Well done, John. Now, if we could just get the bloody OPs to do the same thing, eh? ;-)
May 14 '10 at 07:56 PM
Jeff Moden
Thanks Jeff... I started working with SQL Server at a company that has a good set of coding standards and best practices and it includes nicely formatted code. For debug work and research purposes having something that is half way readable is always a plus...
May 15 '10 at 10:42 AM
John Franklin
(comments are locked)
|

