VbzCart/docs/queries/qryStock by Opt Type

From Woozle Writes Code
< VbzCart‎ | docs‎ | queries
Revision as of 13:18, 10 December 2008 by imported>Woozle (New page: ==About== * '''Returns''': Stock totals by itemoption+itemtype * '''Requires''': {{vbzcart/table|cat_items}}, {{vbzcart/table|cat_ittyps}}, {{vbzcart/query|qryStkItms_for_sale}} * '''Used ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

About

SQL

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

 io.ID AS ID_Opt,
 it.ID AS ID_Typ,
 io.CatKey,
 io.Sort,
 it.NameSng AS TypeSing,
 IFNULL(it.NamePlr,it.NameSng) AS TypePlur,
 SUM(stk.QtyForSale) AS QtyForSale,
 Count(it.ID) AS TypeCount

FROM

       ((cat_ioptns AS io
     LEFT JOIN cat_items AS i ON i.ID_ItOpt=io.ID)
   LEFT JOIN cat_ittyps AS it ON i.ID_ItTyp=it.ID)
 LEFT JOIN qryStkItms_for_sale AS stk ON i.ID=stk.ID_Item

GROUP BY it.ID, io.ID, io.CatKey, io.Sort, it.NamePlr, it.NameSng HAVING QtyForSale ORDER BY io.Sort;</mysql> <section end=sql />