VbzCart/docs/queries/qryStock Titles most recent

From Woozle Writes Code
< VbzCart‎ | docs‎ | queries
Jump to navigation Jump to search

Details

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 />