---Dipesh Tare & Gajanan Sontakke---
---Extra Assignment---

1)
     create table Salespeople
A)
     insert into Salespeople values()
2)
     create table Customers
A)
     insert into Customers values()
3)
     create table orders
A)
     insert into Orders values()

Queries:----

1)
     Q-2) List all customers with a rating of 100.
     ans1) select * from Customers where Ratings=100;
     ans2) select cname from Customers where Ratings=100;
2)
    Q-3) Find all records in the Customer table with NULL values in the city
column.
    ans) select * from Customers where CITY=NULL;
3)
    Q-5) Arrange the Orders table by descending customer number.
    ans) select CNUM from Orders order by CNUM desc;
4)
    alter table customers add constraint pk1 primary key(cnum);
5)
     alter table customers add constraint fk1 foreign key(snum) references
salespeople;
6)
    alter table orders add constraint fk2 foreign key(cnum) references
customers(cnum);
7)
     alter table orders add constraint fk3 foreign key(snum) references
salespeople(snum);
8)
    Q-4) Find the largest order taken by each salesperson on each date.
     ans) select max(amt),odate from orders group by odate;
9)
    Q-5) Arrange the Orders table by descending customer number.
    ans) select cnum from orders order by cnum desc;
10)
    Q-6) Find which salespeople currently have orders in the Orders table.
    ans) select SNUM from orders where odate='10-JUN-96';
11)
    Q-7) List names of all customers matched with the salespeople serving them.
    ans) select cname from customers where 's.sname'='c.cname';
12)
    Q-8) Find the names and numbers of all salespeople who had more than one
customer.
    ans) select count(snum),snum from orders group by snum;

       COUNT(SNUM)        SNUM
       ------- ----------
             2       1003
             3       1001
             2       1002
             2       1007
             1       1004
13) Q-10) List the Customer table if and only if one or more of the customers in
the Customer table are located in San Jose.
   ans) select * from customers where city='San Jose';

  CNUM CNAME           CITY               RATINGS        SNUM
------ --------------- --------------- ---------- ----------
  2003 Liu             San Jose               200        1002
  2008 Cisneros        San Jose               300        1007
14) Q-15) List all the orders of salesperson Motika from the Orders table.
    ans) select count(onum) from orders where snum=1004;

      COUNT(ONUM)
      -------
                1
15) Q-16) Find all customers with orders on October 3.
    ans) select cnum from orders where odate='3/oct/1996';

         no rows selected
16) Q-17) Give the sums of the amounts from the Orders table, grouped by date,
eliminating all those dates where the SUM was not at least 2000.00 above the MAX
amount.
    ans) select SUM(amt),odate from orders group by odate having
SUM(amt)>max(amt)+2000.00 ;

  SUM(AMT) ODATE
---------- ---------
   8944.59 10-MAR-96
16) Q-18)

Extra assign

  • 1.
    ---Dipesh Tare &Gajanan Sontakke--- ---Extra Assignment--- 1) create table Salespeople A) insert into Salespeople values() 2) create table Customers A) insert into Customers values() 3) create table orders A) insert into Orders values() Queries:---- 1) Q-2) List all customers with a rating of 100. ans1) select * from Customers where Ratings=100; ans2) select cname from Customers where Ratings=100; 2) Q-3) Find all records in the Customer table with NULL values in the city column. ans) select * from Customers where CITY=NULL; 3) Q-5) Arrange the Orders table by descending customer number. ans) select CNUM from Orders order by CNUM desc; 4) alter table customers add constraint pk1 primary key(cnum); 5) alter table customers add constraint fk1 foreign key(snum) references salespeople; 6) alter table orders add constraint fk2 foreign key(cnum) references customers(cnum); 7) alter table orders add constraint fk3 foreign key(snum) references salespeople(snum); 8) Q-4) Find the largest order taken by each salesperson on each date. ans) select max(amt),odate from orders group by odate; 9) Q-5) Arrange the Orders table by descending customer number. ans) select cnum from orders order by cnum desc; 10) Q-6) Find which salespeople currently have orders in the Orders table. ans) select SNUM from orders where odate='10-JUN-96'; 11) Q-7) List names of all customers matched with the salespeople serving them. ans) select cname from customers where 's.sname'='c.cname'; 12) Q-8) Find the names and numbers of all salespeople who had more than one customer. ans) select count(snum),snum from orders group by snum; COUNT(SNUM) SNUM ------- ---------- 2 1003 3 1001 2 1002 2 1007 1 1004
  • 2.
    13) Q-10) Listthe Customer table if and only if one or more of the customers in the Customer table are located in San Jose. ans) select * from customers where city='San Jose'; CNUM CNAME CITY RATINGS SNUM ------ --------------- --------------- ---------- ---------- 2003 Liu San Jose 200 1002 2008 Cisneros San Jose 300 1007 14) Q-15) List all the orders of salesperson Motika from the Orders table. ans) select count(onum) from orders where snum=1004; COUNT(ONUM) ------- 1 15) Q-16) Find all customers with orders on October 3. ans) select cnum from orders where odate='3/oct/1996'; no rows selected 16) Q-17) Give the sums of the amounts from the Orders table, grouped by date, eliminating all those dates where the SUM was not at least 2000.00 above the MAX amount. ans) select SUM(amt),odate from orders group by odate having SUM(amt)>max(amt)+2000.00 ; SUM(AMT) ODATE ---------- --------- 8944.59 10-MAR-96 16) Q-18)