VbzCart/docs/queries/qryItTypsDepts grpItems: Difference between revisions
Jump to navigation
Jump to search
imported>Woozle (used by) |
imported>Woozle (using sub-query instead of doing the JOIN right here) |
||
Line 1: | Line 1: | ||
==About== | ==About== | ||
* '''Requires''': {{vbzcart/ | * '''Requires''': {{vbzcart/query|qryCat_Items_Stock}}, {{vbzcart/table|cat_titles}} | ||
* '''Used by''': {{vbzcart/query|qryItTypsDepts_ItTyps}} | * '''Used by''': {{vbzcart/query|qryItTypsDepts_ItTyps}} | ||
* '''History''': | * '''History''': | ||
** '''2009-04-12''' No longer caching stock-quantity fields in cat_items, so had to pull in v_stk_items_remaining; removing cntStkForSale until I find out what it is needed for | ** '''2009-04-12''' No longer caching stock-quantity fields in cat_items, so had to pull in <s>v_stk_items_remaining</s> qryCat_Items_Stock; removing cntStkForSale until I find out what it is needed for | ||
==SQL== | ==SQL== | ||
<section begin=sql /><mysql>CREATE OR REPLACE VIEW qryItTypsDepts_grpItems AS | <section begin=sql /><mysql>CREATE OR REPLACE VIEW qryItTypsDepts_grpItems AS | ||
Line 11: | Line 11: | ||
SUM(IF(i.isForSale,1,0)) AS cntForSale, | SUM(IF(i.isForSale,1,0)) AS cntForSale, | ||
SUM(IF(i.isInPrint,1,0)) AS cntInPrint, | SUM(IF(i.isInPrint,1,0)) AS cntInPrint, | ||
/* SUM(IF( | /* SUM(IF(i.QtyForSale>0,1,0)) AS cntStkForSale, */ | ||
SUM( | SUM(i.qtyForSale) AS qtyForSale | ||
FROM | FROM qryCat_Items_Stock AS i LEFT JOIN cat_titles AS t ON i.ID_Title=t.ID | ||
GROUP BY i.ID_ItTyp, t.ID_Dept | GROUP BY i.ID_ItTyp, t.ID_Dept | ||
HAVING cntForSale;</mysql> | HAVING cntForSale;</mysql> | ||
<section end=sql /> | <section end=sql /> |
Revision as of 01:29, 13 April 2009
About
- Requires: Template:Vbzcart/query, Template:Vbzcart/table
- Used by: Template:Vbzcart/query
- History:
- 2009-04-12 No longer caching stock-quantity fields in cat_items, so had to pull in
v_stk_items_remainingqryCat_Items_Stock; removing cntStkForSale until I find out what it is needed for
- 2009-04-12 No longer caching stock-quantity fields in cat_items, so had to pull in
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(i.QtyForSale>0,1,0)) AS cntStkForSale, */ SUM(i.qtyForSale) AS qtyForSale
FROM qryCat_Items_Stock AS i 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 />