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 |
taunt
Posting Yak Master
128 Posts |
Posted - 2014-01-27 : 19:31:55
|
Hello what I'm trying to do is I have a table items, that I'm tring to display sku, upc, artist, itemname. The only thing is it keeps showing me multiple results with the upc duplicated. I would like it to show me all of the above with only one upc result. I can do it by using discinct, but I can't see sku, artist and itemname. I've also tried group by, but the issue is the some times the sku changes or artist name or itemname. Is there an better way to do this? Hope this makes sense. |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2014-01-27 : 22:37:04
|
that means in your data, for once UPC, you have multiple rows and may have different artist, item name etc.So which one of the row do you want to show ? KH[spoiler]Time is always against us[/spoiler] |
|
|
sqlsaga
Yak Posting Veteran
93 Posts |
Posted - 2014-01-28 : 00:56:01
|
you might have similar upc for differnt sku / artist / itemname. so you are seeing the duplicates which looks like legitimate.Visit www.sqlsaga.com for more t-sql snippets and BI related how to's. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2014-01-28 : 03:22:23
|
quote: Originally posted by taunt Hello what I'm trying to do is I have a table items, that I'm tring to display sku, upc, artist, itemname. The only thing is it keeps showing me multiple results with the upc duplicated. I would like it to show me all of the above with only one upc result. I can do it by using discinct, but I can't see sku, artist and itemname. I've also tried group by, but the issue is the some times the sku changes or artist name or itemname. Is there an better way to do this? Hope this makes sense.
If you want to show all of associated sku,artist,items for upc you need to show them in delimited format or pivot them to different columns if you've multiples per upc value so that upc doesnt get duplicatedHave a look at PIVOT operator to understand how to pivothttp://visakhm.blogspot.in/2012/04/display-total-rows-with-pivotting-in-t.htmland for making delimited list seehttp://visakhm.blogspot.in/2014/01/rowset-concatenation-with-special.html------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|
|
|