September 26, 2007 at 9:09 am
I have a table with ProductId, ItemId, PropertyId, and ValueId columns. My ValueId is a varchar(20) and happens to be the data I want pivoted under the PropertyId which would be my columns. ProductId and ItemId would be the row. Is there a way to do this with Pivot?
thanks,
vmon
September 26, 2007 at 9:17 am
Sorry, but no. The PIVOT operator requires some sort of aggregation. Whether you're averaging or summing or whatever.
Someone did post a CASE statement SELECT which is a fake pivot, though. Check out this thread: http://www.sqlservercentral.com/Forums/Topic399930-338-1.aspx
September 26, 2007 at 9:20 am
well - for better or for worse - Min( [varchar]) returns the [varchar], so you could use that as your aggregate. Assuming you can make sure that the grouping only returns one valueID per column+row grouping, that should give you what you wish.
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
September 26, 2007 at 12:01 pm
Totally agree with Matt and you can use either Min or Max ... just be carefull if you have Nulls !
* Noel
September 27, 2007 at 12:03 am
...or duplicated data...
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply