I have a table named ‘sales’ with following fields
salesid (type: int)
stime (type: datetime)
status (type: enum, values: remaining OR cancelled OR done)
... and other fields
I need a query that can output as
SalesDate TotalSales TotalDone TotalRemaining TotalCancelled
2010-11-06 10 5 3 2
2010-11-06 15 14 1 0
Anyone know how to achieve this?
Help appreciated, thanks.
Use a
CASEstatement in yourSELECTto create pseudo columns using the status values ofremaining, cancelledanddoneNote: This is what i was trying to refer to. I think this should work but i have no access to MySQL to try out the syntax and verify it. Sorry about that. But this should get you going.