VbzCart/docs/queries/qryStock Titles most recent
Jump to navigation
Jump to search
Details
- Requires: Template:Vbzcart/query, Template:Vbzcart/table, Template:Vbzcart/query
- Used by: This defines what the "latest stock" web page shows; as given here, it displays the 100 titles most recently added to stock.
SQL
<section begin=sql /><mysql>CREATE OR REPLACE VIEW qryStock_Titles_most_recent AS SELECT
i.ID_Title, s.QtyForSale AS QtyAdded, MAX(s.WhenAdded) AS WhenAdded, st.QtyForSale AS QtyAvail
FROM (v_stk_lines_remaining AS s LEFT JOIN cat_items AS i ON s.ID_Item=i.ID) LEFT JOIN v_stk_titles_remaining AS st ON i.ID_Title=st.ID_Title GROUP BY i.ID_Title HAVING QtyAdded ORDER BY WhenAdded DESC LIMIT 100;</mysql> <section end=sql />