March 1, 2012 at 8:09 am
Dear All,
I have a select query,that select all data from ‘policy’ table based an ‘agentid’.
Select * from policy where agentid = ‘232’
This ‘policy’ table has expirydate field (date range 31/12/2012 to 01/02/2013) this show the date of policy expiry. Each date contain many policies
Now I want to divide the output in to 3 distinct lists based on expiry date. Each list need to contain unique record.ie.if the record exists in list 1 need to be ignore in the other 2 list
For ex: I need the output be
Query one – list one
FOI1334816 01/03/2012 Mr sharon peckham
TOI3454563 07/12/2012 Mr elizabeth goddard
RTY8383831 12/06/2012 Mr Natalie Door
Query 2 – list 2
BOC1334846 01/03/2012 Mr Natalie Nunes
LOI7853532 07/12/2012 Mr Door D
ASE4472894 12/06/2012 Mr Michelle Hill
Query 3 - list 3
CIL1334894 01/03/2012 Mr Maxine Skelton
BNM7488480 07/12/2012 Mr peckham Nunes
DER5357323 12/06/2012 Mr Graham Lee
How to alter the select query.I have no issue in executing 3 separate query to get this result. Any help regarding this would be highly appreciated
Thanks in advance.
Regards,
SG
March 1, 2012 at 8:50 am
If you would follow this: http://www.sqlservercentral.com/articles/Best+Practices/61537/
you would already have an answer.
March 1, 2012 at 10:34 am
Yes much like your other post, there just simply is not any information for anybody to begin helping. Give us some details and you will be rewarded with some results.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply