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 |
|
tyrant911
Starting Member
1 Post |
Posted - 2011-09-02 : 14:45:56
|
| Hello,I'm trying to make my data display every order once, this includes customers with multiple purchases that are taking up multiple rows with the same data. Those duplicate addressed I don't want them to show up.SELECT color, size, Coupon#, FirstName, LastName, Address + ', ' + City+ ', ' + Province+ '. ' + PostalCode+ ' ' + Country AS "Shipping Address" FROM [Orders] WHERE FirstName IN (SELECT DISTINCT FirstName FROM [Orders])GROUP BY FirstName, LastName, 'Shipping Address';I know the problem is me, but it has been years since i took a sql class and don't really know where to turn to get my queries checked.This is being done on MS SQL 2008 R2 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-02 : 20:29:19
|
| [code]SELECT <required columns>FROM(SELECT ROW_NUMBER() OVER (PARTITION BY FirstName, LastName ORDER BY Address + ', ' + City+ ', ' + Province+ '. ' + PostalCode+ ' ' + Country) AS Seqcolor, size, [Coupon#], FirstName, LastName, Address + ', ' + City+ ', ' + Province+ '. ' + PostalCode+ ' ' + Country AS [Shipping Address]FROM [Orders])tWHERE Seq=1[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|