VbzCart/queries/qryTitles ItTyps grpItems
Jump to navigation
Jump to search
About
- Purpose:
This is a subquery for
REDIRECT Template:l/vc/query; all the summing across items within a Title-ItTyp pair is done here, then the results are joined back with Titles so we have all the information to display.
- Requires: qryCat_Items_Stock
- Used by: qryTitles_ItTyps_Titles
- Notes:
- This is essentially the same query as qryItTypsDepts_grpItems but grouped by ID_Title (and ID_ItTyp) instead of ID_Dept (and ID_ItTyp).
- I originally had a HAVING cntInStock at the end of this, but that results in only stock items showing as available at all. If this filtering is needed for something, it will have to be expressed in some other way.
- History:
- 2008-04-04 Grouping by GrpCode (and GrpDescr and GrpSort) is not necessary, and creates clutter in the title display if used. Certain items which have subtypes only distinguished by the group code (e.g. SD-NF-320 comes in both black and tie-dye) use these fields, but the page-generation code looks for different subtypes in the cat_items data and displays a new subtype header whenever GrpDescr changes. Maybe later on we'll include ID_CtgGroup in cat_items and pull GrpCode, GrpDescr, and GrpSort from the appropriate table(s?), but for now we store the values explicitly in cat_items and rely on proper sorting.
- If subtypes are not being properly disambiguated within the title display, make sure the GrpDescr fields are being given a value (description). This is only necessary when the item type (ID_ItTyp) is the same.
- 2008-04-13 replaced cat_items with qryCat_Items_Stock because qtyForSale is no longer being cached in cat_items.qtyInStock
- 2008-04-04 Grouping by GrpCode (and GrpDescr and GrpSort) is not necessary, and creates clutter in the title display if used. Certain items which have subtypes only distinguished by the group code (e.g. SD-NF-320 comes in both black and tie-dye) use these fields, but the page-generation code looks for different subtypes in the cat_items data and displays a new subtype header whenever GrpDescr changes. Maybe later on we'll include ID_CtgGroup in cat_items and pull GrpCode, GrpDescr, and GrpSort from the appropriate table(s?), but for now we store the values explicitly in cat_items and rely on proper sorting.
SQL
<mysql>CREATE OR REPLACE VIEW qryTitles_ItTyps_grpItems AS SELECT
ID_Title, ID_ItTyp, SUM(IF(isForSale,1,0)) AS cntForSale, SUM(IF(isInPrint,1,0)) AS cntInPrint, SUM(IF(qtyForSale>0,1,0)) AS cntStkForSale, SUM(qtyForSale) AS qtyForSale, MIN(PriceSell) AS currMinPrice, MAX(PriceSell) AS currMaxPrice
FROM qryCat_Items_Stock AS i WHERE isForSale GROUP BY ID_ItTyp, ID_Title;</mysql>