Using Pivot in MySQL

Last Reply 5 months ago By kalpesh

Posted 5 months ago

Hi sir/mam, 

I'm pulling some data from the database and displaying in GridView But i need to display some data in common way like horizontally and some values as vertically. 


Suppose i pulling the id, date, name from the users table.The id and date should come horizontally but the name should come vertically. 

How can show that please help me.

i'm using mysql database

You are viewing reply posted by: kalpesh 5 months ago.
Posted 5 months ago Modified on 5 months ago

First try this

	  ,CASE WHEN UPPER(ob.ProductName) = 'BOOKS' THEN ob.qty ELSE 0 END Books
from orderdata od INNER JOIN orderbooking ob
on  od.OId = ob.BId
where  od.BillDate >=fdate
AND od.BillDate <=tdate
AND ob.BillDate = od.BillDate
AND ob.Status =1
group by (ob.InvoiceNo)

Then try to impliment for dynamic query for MYSQL as explained in previous reply.


I agree, here is the link: