VbzCart/queries/qryItTypsDepts grpItems

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
< VbzCart‎ | queries
Revision as of 18:40, 30 November 2008 by Woozle (talk | contribs) (moved from single-page listing)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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>