VbzCart/docs/queries/qryRstkReq by status

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

About

SQL

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

 r.ID,
 CAST(
   CONCAT(
     CAST(COALESCE(
       CONCAT('X ',DATE_FORMAT(r.WhenKilled,'%Y-%m-%d')),
       CONCAT('O ',DATE_FORMAT(r.WhenOrdered,'%Y-%m-%d')),
       CONCAT('C ',DATE_FORMAT(r.WhenCreated,'%Y-%m-%d'))
     ) AS BINARY),
     ' ',
     s.CatKey,
     IFNULL(CONCAT(' [',r.PurchOrdNum,']'),)
   ) AS CHAR
 ) AS Descr,
 NOT IsLocked AS IsOpen,
 r.WhenOrdered,
 r.WhenConfirmed,
 r.ID_Supplier

FROM rstk_req AS r LEFT JOIN cat_supp AS s ON r.ID_Supplier=s.ID ORDER BY COALESCE(r.WhenKilled,r.WhenOrdered,r.WhenCreated) DESC;</mysql> <section end=sql />