ranjan ranjan - 1 year ago 74
MySQL Question

MySQL:-Displaying results in a single row

I have a query which is working fine but the results are displaying in multiple columns.
Query with result.

But I want the results into a single row like

closed Open Cancelled
2 1 3

Answer Source

The GROUP BY clause will return one row for each value grouped by. Since you have three material_status values you are getting three rows returned. Simply remove that clause and you will get one line in the results since all of your columns are aggregate.

FROM purchase_order

The ORDER BY clause is also not necessary since you are only returning one row.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download