Skip to content

Instantly share code, notes, and snippets.

@agawronski
Created December 11, 2017 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agawronski/977375a0d49214c89e1d321527422d1e to your computer and use it in GitHub Desktop.
Save agawronski/977375a0d49214c89e1d321527422d1e to your computer and use it in GitHub Desktop.
Basic questions about purchasing orders.
-- When did these orders occur ?
-- How many records are there?
-- How many orders are there?
select
min(duedate) as min_duedate,
max(duedate) as max_duedate,
count(*) as num_records,
count(distinct purchaseorderid) as num_orders
from purchasing.purchaseorderdetail;
-- looks like purchaseorderheader has the actual order date
select
min(orderdate) as min_orderdate,
max(orderdate) as max_orderdate,
count(*) as num_records,
count(distinct purchaseorderid) as num_orders
from purchasing.purchaseorderheader;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment