Sales queries

From FreekiWiki
Revision as of 13:35, 22 January 2011 by Leah (talk | contribs) (→‎Queries)
Jump to navigation Jump to search

Useful Info for Queries

Job IDs:

  • Sales Admin - 124
  • Safari - 111
  • Thrift Store - 16
  • Meeting Prep - 108
  • Meeting - 118
  • Thrift Store Admin - 135
  • Online Sales - 68

Worker IDs:

  • Leah - 70001
  • Ian - 53617
  • Tony - 60007
  • Paco - 50838
  • Mike - 70017
  • Luiz - 31639
  • Sergio - 34779
  • E-beth - 60002
  • Sophia - 12386

Queries

  • Total of Monthly XX hours logged (fill in job_id):

SELECT EXTRACT (MONTH FROM worked_shifts.date_performed) AS Monthly, SUM (duration) FROM worked_shifts WHERE date_performed BETWEEN ('2010-01-01') AND ('2010-12-31') AND job_id ='XX' GROUP BY 1 ORDER BY Monthly ASC;

  • Total of Monthly XX hours logged for XXXXX worker (fill in job_id and worker_id):

SELECT EXTRACT (MONTH FROM worked_shifts.date_performed) AS Monthly, SUM (duration) FROM worked_shifts WHERE date_performed BETWEEN ('2010-01-01') AND ('2010-12-31') AND job_id = 'XX' AND worker_id = 'XXXXX' GROUP BY 1 ORDER BY Monthly ASC;