0

以下の表から総在庫と利用可能な在庫を見つける必要があります。テーブル構造:

[Inventoryid] [inventory Type ] [issue status]
1              Mobile            Issued
2              Tablet            Not Issued
3              Mobile            Issued
4              Tablet            Not Issued

必要なアウトポットは

[Inventory Type] [Total Inventory]  [Available Inventory]
Mobile            2                  0
Tablet            2                  2

私に同じ質問をしてください。

4

2 に答える 2

4
SELECT  inventoryType,
        COUNT(*) totalInventory,
        SUM(issuestatus = 'not issued') available
FROM    tableName
GROUP   BY inventoryType
于 2013-01-23T09:20:30.010 に答える
1
select inventory_type , count(*), sum(case when issue_Status = 'not issued' then 1
else 0 end) as status
From yourtable
group by inventory_type
;
于 2013-01-23T09:22:05.563 に答える