Additional Sample Data for Customer Table CustomerID CustomerName CustomerAddres
ID: 3818727 • Letter: A
Question
Additional Sample Data for Customer Table CustomerID CustomerName CustomerAddressID 1 Western Supply Company 1 2 Nick Harper 3 3 Alice Harper 3 4 Abacus Consulting 4 Additional Sample Data for the Address Table AddressID Street City State Zip Code 1 2400 Broadway Drive Missoula MT 59802 2 320 21st Street Billings MT 59101 3 439 Skyline Blvd Denver CO 80002 4 56 Park Avenue New York NY 10001 4. Construct and execute a sql query to count the number of customers in each state. The list should be ordered by the number of customers in descending order then by state code in ascending order 7. Construct and execute a SQL query to list the state and zip code in a single column. The list should not contain any duplicate records and should be sorted in descending alphabetical order
Explanation / Answer
sql query to count the number of customers in each state. The list should be ordered by the number of
customers in descending order then by state code in ascending order
select count(c.customerID) as count, a.state from customer c, address a where c.CustomerAddressID=a.AddressID group by a.state order by count desc, a.state desc
SQL query to list the state and zip code in a single column. The list should not contain any duplicate records and should be sorted in descending alphabetical order
SELECT distinct (state + ', ' + zipcode) AS stateZip FROM (select state, zipcode from Address order by state desc) as addr
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.