VbzCart/docs/queries/qryItTypsDepts grpItems

From Woozle Writes Code
< VbzCart‎ | docs‎ | queries
Revision as of 01:12, 13 April 2009 by imported>Woozle (used by)
Jump to navigation Jump to search

About

SQL

<section begin=sql /><mysql>CREATE OR REPLACE VIEW qryItTypsDepts_grpItems AS SELECT

 i.ID_ItTyp, t.ID_Dept,

 SUM(IF(i.isForSale,1,0)) AS cntForSale,
 SUM(IF(i.isInPrint,1,0)) AS cntInPrint,
 /* SUM(IF(st.QtyForSale>0,1,0)) AS cntStkForSale, */
 SUM(st.qtyForSale) AS qtyForSale

FROM (cat_items AS i LEFT JOIN v_stk_items_remaining AS st on i.ID=st.ID_Item) LEFT JOIN cat_titles AS t ON i.ID_Title=t.ID GROUP BY i.ID_ItTyp, t.ID_Dept HAVING cntForSale;</mysql> <section end=sql />