HI,
We have a table that looks like the following:
id,username,password,area,order_id
1,joe,88,5,100
2,joex,99,5,102
3,joey,77,5,NONE
4,jane,66,4,101
5,janey,22,4,NONE
What we want to do is have the results displayed as
Area, Available, Issued
5 1 2
4 1 1
Originally we had 2 tables. The SQL statements were
SELECT area, COUNT(*) as cnt_used FROM table_name WHERE order_id != 'NONE'
and
SELECT area, COUNT(*) as cnt_used FROM table_name WHERE order_id = 'NONE'
This last one doesn't display 0 and that's critical.
So we thought of combining the two statments and getting one results. We use the case statement on the order_id column and then count on the two different cases.
No luck so far. Any help appreciated.
Thanks,
Jer
We have a table that looks like the following:
id,username,password,area,order_id
1,joe,88,5,100
2,joex,99,5,102
3,joey,77,5,NONE
4,jane,66,4,101
5,janey,22,4,NONE
What we want to do is have the results displayed as
Area, Available, Issued
5 1 2
4 1 1
Originally we had 2 tables. The SQL statements were
SELECT area, COUNT(*) as cnt_used FROM table_name WHERE order_id != 'NONE'
and
SELECT area, COUNT(*) as cnt_used FROM table_name WHERE order_id = 'NONE'
This last one doesn't display 0 and that's critical.
So we thought of combining the two statments and getting one results. We use the case statement on the order_id column and then count on the two different cases.
No luck so far. Any help appreciated.
Thanks,
Jer