question

FriendOfGhost avatar image
FriendOfGhost asked

SQL Pivot Query

Hi friends... I event don't know the name of what I am trying to do to google it.. I'm using sql2008 and here's the problem: 3 tables must be come together to form the table I wrote below.. SOURCE TABLES:

                    
Productstable                     
----------------                    
beer                     
keyboard                     
chair                     
                    
SalesPointstable                     
------------------                     
newyork                    
berlin                    
moscov                    
zurich                    
                    
                    
SalesPricesTable                    
--------------------------------                    
beer..........newyork..4..USD                    
beer..........berlin...5..EURO                    
beer..........moscov...6..ROUBLE                    
beer..........zurich...7..FRANK                    
keyboard......newyork..6..USD                    
keyboard......berlin...7..EURO                    
keyboard......moscov...8..ROUBLE                    
keyboard......zurich...7..FRANK                    
chair.........newyork..6..USD                    
chair.........berlin...7..EURO                    
chair.........moscov...8..ROUBLE                    
chair.........zurich...6..FRANK                    

I need this result table:

                    
................newyork....berlin...moscov....zurich                    
beer........4.USD....5.EURO..6.ROUBLE...7.FRANK                    
keyboard....6.USD....7.EURO..8.ROUBLE...7.FRANK                    
chair.......6.USD....7.EURO..8.ROUBLE...6.FRANK                    

what can be the query ? I could not do it with pivot commands nor I could not designed this query.

any idea would be great. best regards. (sorry for formatting, editor didn't let me do everything)

querypivot
3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Kristen avatar image Kristen ♦ commented ·
"editor didn't let me do everything" Oh yes it does! You didn't bother to read the formatting help which is shown just to the right of where you asked the question!!
0 Likes 0 ·
Madhivanan avatar image Madhivanan commented ·
I see almost all the questions edited by you [:D]
0 Likes 0 ·
Kristen avatar image Kristen ♦ commented ·
Yes, good point; at least this OP acknolwedged that they hadn't been able to format it :)
0 Likes 0 ·

1 Answer

·
Madhivanan avatar image
Madhivanan answered
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.