VbzCart/queries/qryRstkReq by status

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
< VbzCart‎ | queries
Revision as of 18:59, 22 December 2008 by Woozle (talk | contribs) (corrected name of final query)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

About

  • Purpose: One of two queries which are UNIONed to create
  1. REDIRECT Template:l/vc/query
  • Requires:
  1. REDIRECT Template:l/vc/table, cat_supp
  • History:
    • 2008-12-22 Adapted from the discarded query qryCbxRestock_by_status

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>