MySQL - Product a PIVOT resultset

Hi,
Is there a way  to generate a PIVOT resultset with Select Statement from MySQL as it the case with MS SQL?

Regards
Omer-PitouAsked:
Who is Participating?
 
arnoldConnect With a Mentor Commented:
select productid, zipcode as "zipcode",sum(quantity) from tablename group by productid

The attempt is to convert the value in zipcode to be made the column name using the as.


Have not tested .....
0
 
arnoldConnect With a Mentor Commented:
yes, you can use case or if to pull the data out.
There is no pivot table as in built in mechanism.


select column
if column reference check, value as column reference,
if column reference1 check, value as column reference1,
if column reference2 check, value as column reference2,

group by ...

if you post sample data, ............
0
 
Omer-PitouAuthor Commented:
Here is a sample
ZipCode OrderNumber CustomerID ProductID OrderQty ...

I want to ZipCode in columns, ProductID in rows, and count(Qty) at the intersection.
0
 
arnoldConnect With a Mentor Commented:
If I am not mistaken, pivot deals with extracting data in rows and displaying them in columns/

id, type, value
type can be  type1,type2,type3

the pivot would make
id type1 value ,type2 value ,type3 value

can you post an actual data sample

lets say you have

zipcode1,order1,customer1,product1,12
zipcode2,order2,customer2,product1,13

you want the result to be
product1,zipcode1,zipcode2,25
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.