Skip to content

Instantly share code, notes, and snippets.

@agawronski
agawronski / basic_sql_explore_3.sql
Created December 11, 2017 05:22
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;
@agawronski
agawronski / basic_sql_explore_2.sql
Created December 11, 2017 05:19
Look at the top 10 rows of each table in the purchasing schema.
select *
from purchasing.productvendor
limit 10;
select *
from purchasing.purchaseorderdetail
limit 10;
select *
from purchasing.purchaseorderheader
@agawronski
agawronski / basic_sql_explore_1.sql
Created December 11, 2017 05:14
Initial look at the Adventureworks dataset
-- connect to the Adventureworks database
\c Adventureworks
-- view all tables in all schemas
\dt *.*
-- vew all tables in the purchasing schema
\dt purchasing.*