Query 1:: Unique Liquor Stores in Iowa

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Query 1: Unique liquor stores in Iowa

SELECT
count(DISTINCT( store_number)) AS storenum
FROM
`bigquery-public-data.iowa_liquor_sales.sales`
ORDER BY
storenum

Query 2: Storewise sales in liters by year

SELECT
store_number,
upper(store_name) as store_name,
upper(county) as county,
EXTRACT() as wkt,
ROUND(SUM(volume_sold_liters),2) AS liters_sold
FROM
`bigquery-public-data.iowa_liquor_sales.sales`
GROUP BY
store_number,
store_name,
county,
store_location
ORDER BY
store_number,
store_name,
store_location,
liters_sold DESC

Query 3: Explore on GIS viewer

SELECT
store_number,
upper(store_name) as store_name,
upper(county) as county,
ST_GEOGFROMTEXT(store_location) as wkt,
ROUND(SUM(volume_sold_liters),2) AS liters_sold
FROM
`bigquery-public-data.iowa_liquor_sales.sales`
GROUP BY
store_number,
store_name,
county,
store_location
Query 4: Airlines by the total number of flights they have operated

SELECT
airline AS airline,
airline_code AS airlineCode,
nameOfAirline,
COUNT(*) numFlights
FROM
`bigquery-samples.airline_ontime_data.flights` AS flights
JOIN (
SELECT
airline nameOfAirline,
code
FROM
`bigquery-samples.airline_ontime_data.airline_id_codes`) AS codes
ON
flights.airline_code = codes.code
GROUP BY
airline,
airlineCode,
nameOfAirline
ORDER BY
numFlights DESC

Query 5: Airlines by the number of flights they have operated each year

SELECT
EXTRACT(year from TIMESTAMP(date)) as year,
airline AS airline,
airline_code AS airlineCode,
nameOfAirline,
COUNT(*) numFlights
FROM
`bigquery-samples.airline_ontime_data.flights` AS flights
JOIN (
SELECT
airline nameOfAirline,
code
FROM
`bigquery-samples.airline_ontime_data.airline_id_codes`) AS codes
ON
flights.airline_code = codes.code
GROUP BY
year,
airline,
airlineCode,
nameOfAirline
ORDER BY
year,
numFlights DESC,
airlinecode

Query 6: Flights operated by Southwest during 2012

SELECT
departure_airport DEP,
arrival_airport ARR,
COUNT(*) numFlights
FROM
`bigquery-samples.airline_ontime_data.flights`
WHERE
YEAR(date) = 2012
AND airline_code = '19393'
GROUP BY
DEP,
ARR
ORDER BY
numFlights DESC

Query 7: Stackoverflow reputation ranking

SELECT
display_name, location, reputation
FROM `bigquery-public-data.stackoverflow.users`
ORDER BY
reputation DESC
LIMIT 30

You might also like