0% found this document useful (0 votes)
18 views

DM Lab-6

The document describes the creation of tables like salesman, customer, and orders and inserting values into them. It also provides SQL queries to find salesperson and customer belonging to same city, orders between 500-2000 amount and salesperson with their customers and commission.

Uploaded by

Subhash Devalla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

DM Lab-6

The document describes the creation of tables like salesman, customer, and orders and inserting values into them. It also provides SQL queries to find salesperson and customer belonging to same city, orders between 500-2000 amount and salesperson with their customers and commission.

Uploaded by

Subhash Devalla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

LAB-6

2000080025
DEVALLA SATYA SUBHASH

Salesman table creation:


CREATE TABLE salesman(

salesman_id_NO numeric(10) NOT NULL,

salesman_NAME varchar2(50) NOT NULL,

city varchar2(50) NOT NULL,

commision numeric(10,5) NOT NULL);

insert into salesman values(5001,'James Hoog', 'New York',0.15),

insert into salesman values(5002,'Nail Knite','Paris',0.13);

insert into salesman values(5003,'Pit Alex','London',0.11);


insert into salesman values(5004,'Mc Lyon','Paris',0.14);

insert into salesman values(5005,'Paul Adam,','Rome',0.13);

insert into salesman values(5006,'Lauson Hen', 'San Jose',0.12);

select * from salesman;

Customer table customer:


CREATE TABLE customer1(

customer_id_NO numeric(10) NOT NULL,

customer_NAME varchar2(50) NOT NULL,

city varchar2(50) NOT NULL,

grade numeric(10),

sales_man_ID numeric(10) NOT NULL);

insert into customer1 values(3002,'Nick Rimando','New York',100,5001);

insert into customer1 values(3007,'Brad Davis','New York',200,5001);

insert into customer1 values(3005,'Graham Zusi','California',200,5002);

insert into customer1 values(3008,'Julian Green','London',300,5002);

insert into customer1 values(3004,'Fabian Johnson','Paris',300,5006);

insert into customer1 values(3009,'Geoff Cameron','Berlin',100,5003);

insert into customer1 values(3003,'Jozy Altidor','Moscow',200,5007);

insert into customer1 values(3001,'Brad Guzan','London',NULL,5005);


1. From the following tables write a SQL query to find the salesperson
and customer who belongs to same city. Return Salesman, cust_name
and city.
SELECT salesman_NAME,customer_NAME,s.city
FROM salesman s,customer1 c
WHERE s.city=c.city;
Orders table creation:
CREATE TABLE orders(

ord_no numeric(10) NOT NULL,

purch_amt numeric(10,5) NOT NULL,

ord_date date NOT NULL,

customer_id numeric(10) NOT NULL,

salesman_id numeric(10) NOT NULL);

insert into orders values(70001,150.5,'05-oct-2012',3005,5002);

insert into orders values(70009,270.65,'10-sep-2012',3001,5005);

insert into orders values(70002,65.26,'05-oct-2012',3002,5001);

insert into orders values(70004,110.5,'17-oct-2012',3009,5003);

insert into orders values(70007,948.5,'10-sep-2012',3005,5002);

insert into orders values(70005,2400.6,'27-july-2012',3007,5001);

insert into orders values(70008,5760,'10-sep-2012',3002,5001);

insert into orders values(70010,1983.43,'10-oct-2012',3004,5006);

insert into orders values(70003,2480.4,'10-oct-2012',3009,5003);

insert into orders values(70012,250.45,'27-june-2012',3008,5002);

insert into orders values(70011,75.29,'17-aug-2012',3003,5007);

insert into orders values(70013,3045.6,'25-apr-2012',3002,5001);


Customer table creation:
CREATE TABLE customer1(

customer_id_NO numeric(10) NOT NULL,

customer_NAME varchar2(50) NOT NULL,

city varchar2(50) NOT NULL,

grade numeric(10),

sales_man_ID numeric(10) NOT NULL);

insert into customer1 values(3002,'Nick Rimando','New York',100,5001);

insert into customer1 values(3007,'Brad Davis','New York',200,5001);

insert into customer1 values(3005,'Graham Zusi','California',200,5002);

insert into customer1 values(3008,'Julian Green','London',300,5002);

insert into customer1 values(3004,'Fabian Johnson','Paris',300,5006);

insert into customer1 values(3009,'Geoff Cameron','Berlin',100,5003);

insert into customer1 values(3003,'Jozy Altidor','Moscow',200,5007);

insert into customer1 values(3001,'Brad Guzan','London',NULL,5005);


2) From the following tables write a SQL query to find those orders where
order amount exists between 500 and 2000. Return ord_no,
purch_amt, cust_name, city.

SELECT ord_no,purch_amt,customer_NAME,city

FROM orders o,customer1 c

WHERE o.customer_id=c.customer_id_NO

AND o.purch_amt BETWEEN 500 AND 2000;


Cutomer table creation:
CREATE TABLE customer1(

customer_id_NO numeric(10) NOT NULL,

customer_NAME varchar2(50) NOT NULL,

city varchar2(50) NOT NULL,

grade numeric(10),

sales_man_ID numeric(10) NOT NULL);

insert into customer1 values(3002,'Nick Rimando','New York',100,5001);

insert into customer1 values(3007,'Brad Davis','New York',200,5001);

insert into customer1 values(3005,'Graham Zusi','California',200,5002);

insert into customer1 values(3008,'Julian Green','London',300,5002);

insert into customer1 values(3004,'Fabian Johnson','Paris',300,5006);

insert into customer1 values(3009,'Geoff Cameron','Berlin',100,5003);

insert into customer1 values(3003,'Jozy Altidor','Moscow',200,5007);

insert into customer1 values(3001,'Brad Guzan','London',NULL,5005);


Salesman table creation:
CREATE TABLE salesman(

salesman_id_NO numeric(10) NOT NULL,

salesman_NAME varchar2(50) NOT NULL,

city varchar2(50) NOT NULL,

commision numeric(10,5) NOT NULL);

insert into salesman values(5001,'James Hoog', 'New York',0.15),

insert into salesman values(5002,'Nail Knite','Paris',0.13);

insert into salesman values(5003,'Pit Alex','London',0.11);

insert into salesman values(5004,'Mc Lyon','Paris',0.14);

insert into salesman values(5005,'Paul Adam,','Rome',0.13);

insert into salesman values(5006,'Lauson Hen', 'San Jose',0.12);

select * from salesman;

2. From the following tables write a SQL query to find the salesperson(s) and the
customer(s) he handle. Return Customer Name, city, Salesman, commission

SELECT c.customer_NAME,c.city,s.salesman_NAME,s.commision
FROM salesman s,customer1 c
WHERE s.salesman_id_NO=c.sales_man_ID

You might also like