Using Pivot in MySQL

Last Reply 12 days ago By kalpesh

Posted 13 days 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. 

Example

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 12 days ago.
Posted 12 days ago Modified on 12 days ago

First try this

SELECT od.OId
      ,od.SalesCode
	  ,od.InvoiceNo
	  ,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: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html