Question

For each city, list number of customers from the city, who have placed order(s). Cities are...

For each city, list number of customers from the city, who have placed order(s). Cities are listed in ascending alphabetical order. Use equal join for this query.

CREATE TABLE customer (
  cust_id  number(11,0)  not null,
  cust_name  varchar2(25)  not null,
  street  varchar2(30),
  city  varchar2(20),
  state  varchar2(2),
  zipcode  varchar2(5),
CONSTRAINT customer_pk PRIMARY KEY (cust_id) );

CREATE TABLE ordertable (
  order_id  number(11,0)  not null,
  order_date  date,
  cust_id  number(11,0),
CONSTRAINT order_pk PRIMARY KEY (order_id),
CONSTRAINT order_fk FOREIGN KEY (cust_id) REFERENCES customer (cust_id));

CREATE TABLE product (
  product_id  number(11,0)  not null,
  product_name  varchar2(50),
  product_price  number(6,2),
CONSTRAINT product_pk PRIMARY KEY (product_id));

CREATE TABLE orderline (
  order_id  number(11,0)  not null,
  product_id  number(11,0)  not null,
  quantity  number(11,0),
CONSTRAINT orderline_pk PRIMARY KEY (order_id, product_id),
CONSTRAINT orderline_fk1 FOREIGN KEY (order_id) REFERENCES ordertable (order_id),
CONSTRAINT orderline_fk2 FOREIGN KEY (product_id) REFERENCES product (product_id));
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer: select city,count(city) from customer c, ordertable o where c.cust_id = o.cust_id group by city order by city asc;

This query will display for each city, list number of customers from the city, who have placed order(s). Cities are listed in ascending alphabetical order

Add a comment
Know the answer?
Add Answer to:
For each city, list number of customers from the city, who have placed order(s). Cities are...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Having trouble creating SQL data base. Need help trying to correct the following data so that...

    Having trouble creating SQL data base. Need help trying to correct the following data so that it will run... CREATE TABLE CUSTOMER_T (Customer_ID VARCHAR2(10), CUSTOMER_NAME VARCHAR2(50), CUSTOMER_STREET VARCHAR2(50), CUSTOMER_CITY VARCHAR2(25), CUSTOMER_STATE VARCHAR2(2), CUSTOMER_POSTAL_CODE VARCHAR2(9), CUSTOMER_TYPE VARCHAR2(20), LOCATION_ID VARCHAR2(15), CONSTRAINT CUSTOMER_PK PRIMARY KEY (CUSTOMER_ID), CONSTRAINT CUSTOMER_FK FOREIGN KEY(LOCATION_ID) REFERENCES LOCATION_T (LOCATION_ID)); CREATE TABLE LOCATION_T (LOCATION_ID VARCHAR2(15), LOCATION_NAME VARCHAR2(30), LOCATION_COUNTRY VARCHAR2(30), CONSTRAINT LOCATION_PK PRIMARY KEY (LOCATION_ID), CONSTRAINT LOCATION_FK FOREIGN KEY(RATE_ID) REFERENCES LOCATION(LOCATION_ID)); CREATE TABLE RATE_T (RATE_ID VARCHAR2(15), RATE_CLASS VARCHAR2(20), RATE_PER_kwh NUMBER(10,2), CONSTRAINT...

  • An online company sells hundreds of office supply products on its e-Commerce store. It has asked...

    An online company sells hundreds of office supply products on its e-Commerce store. It has asked you to design and implement a sales order processing system which will be used by users in our Operations department to process sales orders. Here is an overview of the sales order process. Customers make purchases by placing orders. Each customer has a customer number and profile (such as name, shipping address). To simplify the matter, each time an order is placed, only one...

  • I NEED TO WRITE THE FOLLOWING QUERIES IN MYSQL (13)Next, grant to a user admin the read privileges on the complete descr...

    I NEED TO WRITE THE FOLLOWING QUERIES IN MYSQL (13)Next, grant to a user admin the read privileges on the complete descriptions of the customers who submitted no orders. For example, these are the customers who registered themselves and submitted no orders so far. The granted privilege cannot be propagated to the other users. 0.3 (14)Next, grant to a user admin the read privileges on information about the total number of orders submitted by each customer. Note, that some customers...

  • Display all customers. If a customer has placed any orders, also display the highest..... Tables: CREATE TABLE Sales.Cu...

    Display all customers. If a customer has placed any orders, also display the highest..... Tables: CREATE TABLE Sales.Customers ( CustomerId          INT          NOT NULL IDENTITY, CustomerName          NVARCHAR(50) NOT NULL, StreetAddress NVARCHAR(50) NULL, City          NVARCHAR(20) NULL, [State]          NVARCHAR(20) NULL, PostalCode         NVARCHAR(10) NULL, Country          NVARCHAR(20) NULL, Contact          NVARCHAR(50) NULL, Email         NVARCHAR(50) NULL, CONSTRAINT PK_Customers PRIMARY KEY(CustomerId) ); CREATE TABLE HR.Employees ( EmployeeId          INT          NOT NULL IDENTITY, FirstName         NVARCHAR(50) NOT NULL, LastName          NVARCHAR(50) NOT NULL, BirthDate         DATE         NOT NULL, HireDate          DATE         NOT NULL, HomeAddress...

  • Create a new database and execute the code below in SQL Server’s query window to create...

    Create a new database and execute the code below in SQL Server’s query window to create the database tables. CREATE TABLE PhysicianSpecialties (SpecialtyID integer, SpecialtyName varchar(50), CONSTRAINT PK_PhysicianSpecialties PRIMARY KEY (SpecialtyID)) go CREATE TABLE ZipCodes (ZipCode varchar(10), City varchar(50), State varchar(2), CONSTRAINT PK_ZipCodes PRIMARY KEY (ZipCode)) go CREATE TABLE PhysicianPractices (PracticeID integer, PracticeName varchar(50), Address_Line1 varchar(50), Address_Line2 varchar(50), ZipCode varchar(10), Phone varchar(14), Fax varchar(14), WebsiteURL varchar(50), CONSTRAINT PK_PhysicianPractices PRIMARY KEY (PracticeID), CONSTRAINT FK_PhysicianPractices_ZipCodes FOREIGN KEY (ZipCode) REFERENCES Zipcodes) go CREATE...

  • SQL Command - Create a view called S LIST that lists the Cardholder Number, last name,...

    SQL Command - Create a view called S LIST that lists the Cardholder Number, last name, first name and due date for all cardholders who have not returned a book. Use the CREATE OR REPLACE VIEW AS ... command. TABLE CARD HOLDERS Cardholder Numberint NOT NULL CONSTRAINT CH PK PRIMARY KEY, First_Name varchar(10) NULL, LastName varchar(15) NULL, Address varchar(20) NULL, varchar(15) NULL, State char(2) NULL, Zip_Code char(5) NULL) City TABLE BOOKS CHECKED OUT Cardholder_Numberint NOT NULL, Book Numberint NOT NULL,...

  • -- Schema definition create table Customer (     cid   smallint not null,     name varchar(20),    ...

    -- Schema definition create table Customer (     cid   smallint not null,     name varchar(20),     city varchar(15),     constraint customer_pk         primary key (cid) ); create table Club (     club varchar(15) not null,     desc varchar(50),     constraint club_pk         primary key (club) ); create table Member (     club varchar(15) not null,     cid   smallint     not null,     constraint member_pk         primary key (club, cid),     constraint mem_fk_club         foreign key (club) references Club,     constraint mem_fk_cust...

  • Determine the company that has the greatest number of travel days out of all reservations. Display...

    Determine the company that has the greatest number of travel days out of all reservations. Display the name of the company and the total number of travel days with the header of SUMDAYS. create table Customer( customerID number, firstName varchar2(15), lastName varchar2(15), address varchar2(30), phone number(10) not null, age number(3), Constraint Customer_PK Primary Key (customerID), constraint Customer_UQ unique (firstName,lastName,phone), constraint Customer_CK check(phone is not null) ); create sequence customerID_seq start with 1 increment by 1; insert into Customer values (customerID_seq.nextval,...

  • Create a procedure to update the sales history table following the requirements below. A table creation...

    Create a procedure to update the sales history table following the requirements below. A table creation script is provided below. a) Call the procedure: UPDATE_SALES_HISTORY (The procedure name is important for our scripts to test and grade your code; please do not rename it (otherwise our scripts will not run and your score will be 0). b) The procedure takes 2 parameters: (4-digit-year, 2-digit-month). Both parameters will be numeric, e.g., (2019, 11) will denote 2019 (year) and November (month). The...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT