VbzCart/queries/qryItTypsDepts grpItems
Jump to navigation
Jump to search
SQL
<mysql>CREATE OR REPLACE VIEW qryItTypsDepts_grpItems AS SELECT
ID_ItTyp, ID_Dept,
SUM(IF(isForSale,1,0)) AS cntForSale, SUM(IF(isInPrint,1,0)) AS cntInPrint, SUM(IF(qtyInStock>0,1,0)) AS cntInStock, SUM(qtyInStock) AS qtyInStock
FROM cat_items AS i LEFT JOIN cat_titles AS t ON i.ID_Title=t.ID GROUP BY ID_ItTyp, ID_Dept HAVING cntForSale;</mysql>