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 |
|
tinamiller1
Yak Posting Veteran
78 Posts |
Posted - 2012-02-14 : 14:37:44
|
| I have a table that I need to split the dates up and only keep dates that are distinct to the ID. Here is an example of what I see:custID orderdate1 orderdate2 12345 12dec2010 12dec2010 12345 15dec2010 15dec2010 43563 01jan2011 01jan2011 43563 06jan2011 06jan2011 79302 15jan2011 15jan2011 94032 25jan2011 02feb2011 The goal is to have all the order dates still if need be but distinct by the custid so the above I would want the output to look like thiscustID orderdate1 orderdate2 12345 12dec2010 15dec2010 43563 01jan2011 06jan2011 79302 15jan2011 94032 25jan2011 02feb2011 This is so I have only 1 distinct custID but the same dates are gotten rid of in the query and the differing dates are kept.tina m miller |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-02-14 : 14:52:26
|
| [code]select custID,min(orderdate1) as orderdate1,max(orderdate2) as orderdate2from tablegroup by custid[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|