sql questions
sql questions
2.- To combine data from two tables, the following clauses are valid:
a) LEFT JOIN
b) INNER JOIN
c) JOIN
d) UNION
FROM city
____________________ ___________________
-------------------------- ---------------------------
adam | president
4.- Given the two tables below, and the following query:
____________________ ___________________
-------------------------- ---------------------------
adam | president
How many rows will have an empty or null value for the column city_name?
5.- Given the two tables below, and the following query:
SELECT jobs.user_id, jobs.title, city.city_name from jobs left join city on jobs.user_id = city.user_id
____________________ ___________________
-------------------------- ---------------------------
adam | president
6.- Given the two tables below, and the following query:
select jobs.user_id, jobs.title, city.city_name from jobs left join city on jobs.user_id = city.user_id
____________________ ___________________
-------------------------- ---------------------------
adam | president
How many rows will have an empty or null value for city ?
7.- Given the table below, which of the following queries will produce the result of 0.56?
Table: Programmatic_cost
8.- Given the table programmatic_cost , which of the queries below will produce the following result?
Table: programmatic_cost
c) select sum(cost) user_id, event_date, campaign_id from programmatic_cost group by user_id, event_date
9.- Given the table adoptions, which query will return the names of dogs adopted before 2019?
Table: adoptions
d) select pet_name from adoptions where species = ´dog´ and adoption_date < ‘2019-01-01’
10.- Given the table adoptions, which query will return cats that weigh more than 10 lbs. along their
adoption date?
Table: adoptions
d) select pet_name, adoption_date from adoptions where species = ‘cat’ and weight > 10
11.- Given the table adoptions, fill in the blank to create a query which will return the earliest
adoption_date in the table
Table: adoptions
12.- Given the table apple_sales , which query below will properly calculate the total production cost
for each product in 2017? Total production cost is defined as the number of units multiplied by the unit
cost
Table: apple_sales
a) select sku, product_name, units*unit_cost as total_production_cost from apple_sales where year = 2017
b) select product, multiply (units, unit_cost) as total_production_cost from apple_sales where year = 2017
c) select sku_product_name, units + unit_cost as total_production_cost from apple_sales where year = 2017
d) select sku, product_name, units x unit_cost as total_production_cost from apple_sales where year = 2017
13.- Net revenue is defined as units multiplied by sale_price minus total production cost.
Which query below will properly calculate net revenue for each product for 2017 and 2018?
Table: apple_sales
a) select sku, p roduct_name, year, units * sale_price + units / unit_cost as total_revenue from apple_sales
b) select sku, product_name, year, (unit/unit_cost) / (sale_price * unit_cost) as total_revenue from apple_sales
c) select sku, product_name, year, (units * sale_price) / unit_cost as total_revenue from apple_sales
d) select sku, product_name, year (units * sale_price) – (units * unit_cost) as total_revenue from apple_sales
Given the table to impressions, which query below will help to answer how many unique user_ids were
reached on each site as a part of campaign 77654?
Table: impressions
a) select count(distinct(user_id)) as unique_reach, site_id from impressions where campaign_id = 77654 group by
site_id
b) select count(site_id) as unique_reach, site_id from impressions where campaign_id = 77654 group by site_id
d) select count(user_id) as unique_reach, site_id, from impressions where campaign_id = 77654 group by site_id
15.- Given the table paid_search, the Ad ID column represents the three major search engines
( google, yahoo, bing)
We would like to create a new column which uses the name of the search engine in place of the ID number.
Fill one word into each blank in the statement below to create the new column.
(case)
(when) ad_id = 311528944 then ‘Google’
(else) ‘other’
(end) as search_engine
Which query will calculate the number of impressions that each user _id saw during campaign 77654?
Table: impressions