Question

I need to make three queries on the table that I have created. The schema for...

I need to make three queries on the table that I have created. The schema for the table is below.

CREATE TABLE IF NOT EXISTS SalesJan2009
   (transaction_date String, product String, price Float, payment_type String,
   name String, city String, state String, country String, account_created String,
   last_login String, latitude Float, longitude Float)
   ROW FORMAT DELIMITED
   FIELDS TERMINATED BY ','
   LINES TERMINATED BY '\n'
   STORED AS TEXTFILE
   tblproperties("skip.header.line.count"="1");

Queries begin here:

Write a query that counts the number of records for each country.

Write a query that counts the number of orders for each product for each country.

Write a query that calculates the total sales for each product for each country (i.e., sum of price).

Homework Answers

Answer #1

If you have any doubts, please give me comment...

-- Write a query that counts the number of records for each country.

SELECT country, COUNT(*) AS noOfRecords

FROM SalesJan2009

GROUP BY country;

-- Write a query that counts the number of orders for each product for each country.

SELECT country, product, COUNT(*) AS noOfOrders

FROM SalesJan2009

GROUP BY country, product;

-- Write a query that calculates the total sales for each product for each country (i.e., sum of price).

SELECT country, product, SUM(price) AS totalSales

FROM SalesJan2009

GROUP BY country, product;

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
I am having trouble writing these queries in MYSQL. Using the schema listed below, please write...
I am having trouble writing these queries in MYSQL. Using the schema listed below, please write the following queries in MYSQL: 1) Find the actors that have movies in all the categories. 2) Movies have a length in minutes. Show a list with all the lengths ordered from shorter to longer, and the number of movies for each of the lengths. 3) Show the 10 first results with the first name, last name and average length of the movies for...
I am having trouble writing these queries in MYSQL. Using the schema listed below, please write...
I am having trouble writing these queries in MYSQL. Using the schema listed below, please write the following queries in MYSQL: 1) Find the actors that have movies in all the categories. 2) Movies have a length in minutes. Show a list with all the lengths ordered from shorter to longer, and the number of movies for each of the lengths. 3) Show the 10 first results with the first name, last name and average length of the movies for...
I am having trouble writing these queries in MYSQL. Using the schema listed below, please write...
I am having trouble writing these queries in MYSQL. Using the schema listed below, please write the following queries in MYSQL: 1) Find all the Comments created by “Mike_34” with a score bigger than 80 2) Find the Film title from all the movies with an actor with first name “TOM”. 3) Find the full name of all the actors in the movies with at least a comment with a score equal to 100. Schema: Consider a movie relational database...
The relational schema for the Academics database is as follows: DEPARTMENT(deptnum, descrip, instname, deptname, state, postcode)...
The relational schema for the Academics database is as follows: DEPARTMENT(deptnum, descrip, instname, deptname, state, postcode) ACADEMIC(acnum, deptnum*, famname, givename, initials, title) PAPER(panum, title) AUTHOR(panum*, acnum*) FIELD(fieldnum, id, title) INTEREST(fieldnum*, acnum*, descrip) Some notes on the Academics database: An academic department belongs to one institution (instname) and often has many academics. An academic only works for one department. Research papers (PAPER) are often authored by several academics, and of course an academic often writes several papers (AUTHOR). A research field...
***** this is question and answer i just need the schema Data Modelling is the primary...
***** this is question and answer i just need the schema Data Modelling is the primary step in the process of database design. Compare and contrast Conceptual data model versus Physical data model. Illustrates with help of example to list down data (entities), relationship among data and constraints on data. Data Modeling:- Data Modeling is the first step in database designing.It is the representation of data model, or collected data. Also shows that collected data stored in database and linked...
SQL Write the queries necessary to obtain the required information 1) Use sub query and “in”...
SQL Write the queries necessary to obtain the required information 1) Use sub query and “in” keyword to print the salesreps (ids) who have taken order for the companies ‘Zetacorp’ or ‘JCP Inc.’ . Duplicate rows are not allowed 2) Use sub query to find the id and the name of every sales rep that represents at least one customer with a credit limit of greater than $5000. 3) Use sub query and keyword “exists” to list the id and...
Please create the queries listed below using the books database under question 4. Thanks for the...
Please create the queries listed below using the books database under question 4. Thanks for the help 1. List the number of books, the minimum price, maximum price, and average sales of history books. The format of output is: Number Min Price Max Price Average Sale 2. List the number of books and the average number of pages published by pub_id P01. 3. List the number of books and the total sales of the books with price greater than $15....
using mysql lyrics.database. i will provide the lyrics schema database info below 1. List the first...
using mysql lyrics.database. i will provide the lyrics schema database info below 1. List the first name, last name, and region of members who do not have an email. 2. List the first name, last name, and region of members who do not have an email and they either have a homephone ending with a 2 or a 3. 3. List the number of track titles that begin with the letter 's' and the average length of these tracks in...
1. What is an ISP (Integrated Service Provider) for supply chains? (1 point) A. A consultant...
1. What is an ISP (Integrated Service Provider) for supply chains? (1 point) A. A consultant agency which integrates the supply chain for companies B. A 2 PL or a 3PL, but not a 4PL C. A company supplying transportation and warehousing services D. A logistics service company specialized in suppling VAS (value added services) 2. What characterizes a 4 PL? (1 point) A. They are non-asset based and provides integrated services primarily supplied by asset based providers, for example...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT