Select multiple counts from one database table in one sql command Select multiple counts from one database table in one sql command database database

Select multiple counts from one database table in one sql command


SELECT   ItemScanPoint,         SUM(CASE ItemType WHEN 1 THEN 1 ELSE 0 END) ,         SUM(CASE ItemType WHEN 2 THEN 1 ELSE 0 END)   FROM     ItemsScan GROUP BY ItemScanPoint


Does this work for you?

select count(ItemScanId), itemscanpoint, itemtypefrom itemsscanwhere itemtype in (1,2)group by itemtype, itemscanpoint


Count is a grouping function in oracle. Try this:

select ItemType, count(ItemType)from ItemsScangroup by ItemType