Académique Documents
Professionnel Documents
Culture Documents
Home
About
Contact
Search for:
STUD_NAM VARCHAR2(20)
CLASS VARCHAR2(20)
39 LEON CSE
34 VIKAS CSIT
18 MATHEW ECE
8 HANSEN MECH
24 ALEXIS EEE
DESCRIPT VARCHAR2(20)
LAB_NO NUMBER(5)
DESCRIPTION VARCHAR2(20)
78 2 chemistry
87 1 edc
12 10 cds
8 3 java lab
STUD_NO NUMBER(5)
MACH_NO NUMBER(5)
DOWEEK VARCHAR2(20)
39 23 sat
34 87 mon
18 78 tue
8 12 wed
24 12 thu
1. List all the machine allotments with the student names, lab and mach no
SQL>select s.studname,l.machno from student1 s,lab l,allotment a
STUDNAME MACHNO
………………………………………..
ABHIJEET 1
KALYAN 22
ASHWIN 3
ARKA 4
ARVIND 5
1. List the total number of lab allotments day wise
SQL>select l.machno,l.descrip,a.day from lab l,allotment a
where a.machno=l.machno;
……………………………………………………………………
1 UNIX MONDAY
22 UNIX TUESDAY
3 XP WEDNESDAY
4 WINDOWS THRUSDAY
5 ME FRIDAY
1. Give a count of how many machines have been allocated to the ‘CSIT’ class
SQL>select count(machno)from allotment where studno in(select studno
COUNT (MACHNO)
……………………..
1
………………………………………………………………………………………………
………
1. Count for how many machines have been allocatedin Lab_no 1 for the day of the week
as “Monday”
1. How many students class wise have allocated machines in the labs
SQL>select count(studno) “allocated students in the labs”,class
group by class;
……………………………………………………………………………
2 CSE
1 ECE
1 EEE
1 IT
1. Create a view which lists out the stud_no, stud_name, mach_no, lab_no, dayofweek
1. Create a view which lists the machine allotment details for “Thursday”
Posted on October 20, 2016
3. Database Schema for a Employee-pay scenario
Create table employee(emp_id int(5) primary key,emp_name varchar2(25));
SQL>desc employee;
………………………………………………………………………………………..
EMP_NAME VARCHAR2(25)
EMP_ID EMP_NAME
………………………………………………………….
10 Robert
21 Coulthard
30 Fernando Alonso
39 Kartikeyan
87 Kimmi
SQL>desc department;
………………………………………………………………………………………..
DEPT_NAME VARCHAR2(20)
DEPT_ID DEPT_NAME
……………………………………………………………………………..
sales
accounts
administration
production
supervisor
SQL>desc paydetails;
………………………………………………………………………………………..
EMP_ID NUMBER(5)
DEPT_ID NUMBER(5)
BASIC NUMBER(7,2)
DEDUCTIONS NUMBER(5,2)
ADDITIONS NUMBER(5,2)
DOJ DATE
&basic,&deductions,&additions,&doj);
………………………………………………………………………………………………
…………………..
SQL>desc payroll;
Name Null? Type
………………………………………………………………………………………..
EMP_ID NUMBER(5)
PAY_DATE DATE
EMP_ID PAY_DATE
………………………………………………………….
10 31-JAN-06
21 03-FEB-06
30 15-JAN-06
39 27-JAN-06
87 04-FEB-06
EMPID DEPTID
…………………………
500
200
600
400
1200
1. List all the employee names who joined after particular date
SQL>select e,empname from employee e,paydet p where e.empid=p.empid
and p.doj>=’05-mar-06’;
EMPNAME
…………………
AVINASH
NITIN
PHALGUN
1. List the details of employees whose basic salary is between 10k and 20k
SQL>Select empid,empname from employee where salary between 10kand 20k;
EMPID EMPNAME
…………………………….
AKHILA
aaaaaaaa
EMPID EMPNAME
…………………………….
AKHILA
………………………………………………………
1 200
1 400
1 500
1 600
1 1200
EMPNAME
………………
AVINASH
AKHILA
HARISH
NITIN
PHALGUN
empid empname
——————————————
5 Coulthard
1. i) Create a view which lists out the emp_name, department, basic, dedeuctions, netsalary
SQL>desc student;
………………………………………………………………………………………..
STUD_NAME VARCAHR2(15)
STUD_NO STUD_NAME
…………………………………………………………..
508 HARISH
513 BALAJI
518 RAKESH
524 PAVAN
534 JOYCE
SQL>dsec membership;
………………………………………………………………………………………………
…….
STUD_NO NUMBER(5)
Errors Observed:
ERROR at line 1:
MEM_NO STUD_NO
………………………………………………………………………..
513
508
518
534
524
SQL>create table book(book_no number(5) primary key,book_name varchar2(20),author
varchar2(2));
SQL>desc book;
………………………………………………………………………………………..
BOOK_NAME VARCHAR2(20)
AUTHOR VARCHAR2(20)
SQL>insert into book values(&book_no,’&book_name’,’&author’);
………………………………………………………………………………………………
..
SQL>desc iss_rec;
………………………………………………………………………………………………
………
ISS_DATE DATE
MEM_NO NUMBER(5)
BOOK_NO NUMBER(5)
………………………………………………………………………………………………
…
where m.studno=s.studno;
STUDNAME MEMNO
————- ——–
abhijeet 1001
arun 1002
arvind 1003
ashish 1004
ashwin 1005
1. List all the issues for the current date with student and Book names
SQL> select i.issno, s.studname, b.bookname from iss_rec I, membership
13 arvind P&S
1. List the details of students who borrowed book whose author is CJDATE
SQL> select * from student where studno in(select studno from
STUDNO STUDNAME
———- ————-
ashwin
1. Give a count of how many books have been bought by each student
SQL> select s.studno, count(i.bookno) from student s.membership m, book b, 2 iss_rec I
where s.studno=m.studno and b.bookno=i.bookno group by s.studno;
STUDNO COUNT(I.BOOKNO)
———- ———————–
501 5
502 5
503 5
504 5
505 5
BOOKNAME
————-
NT
issdate=to_char(sysdate));
delete from book where bookno in (select bookno from iss_rec where
issdate=to_char(sysdate))
Errors Observed:
ERROR at line 1:
1. Create a view which lists out the iss_no, iss _date, stud_name, book name
Create a view which lists the daily issues-date wise for the last one week
Output:
Name Null? Type
CUST_NAME VARCHAR2(15)
Output:
CUST_ID CUST_NAME
———- —————
100 ramu
101 kamal
102 raju
Output:
Name Null? Type
………………………………………………………………………………………………
……
Item_name VARCHAR2(15)
PRICE NUMBER(6,2)
Output:
ITEM_ID ITEM_NAME PRICE
……………………………………………………………………………………..
SQL>dsec sale
Output:
Name Null? Type
………………………………………………………………………………………..
BILL_DATE DATE
CUST_ID NUMBER(5)
ITEM_ID NUMBER(4)
QTY_SOLD NUMBER(4)
Output:
BILL_NO BILL_DATE CUST_ID ITEM_ID QTY_SOLD
………………………………………………………………………………………………
…………
1. c) List all the bills for the current date with the customer names and item numbers
SQL> select c.custname, i.itemid, s.billno from customer c, item I, sale s
s.billdate=to_char(sysdate);
——- —– ——–
120 2 240
20 3 60
5 2 10
10 1 10
350 4 1400
1. e) List the details of the customer who have bought a product which has a price>200
SQL> select c.custid, c.custname from customer c, sale s, item i where i.price>200 and
CUSTID CUSTNAME
——— ————–
duffy
1. Give a count of how many products have been bought by each customer
SQL> select custid, count(itemid) from sale group by custid;
CUSTID COUNT(ITEMID)
———- ———————
1 2
3 1
4 1
5 1
ITEMNAME
————–
Pens
ITEMID ITEMNAME
——— ————-
pencil
1. Create a view which lists out the bill_no, bill_date, cust_id, item_id, price, qty_sold,
amount
SQL>create view cust as (select s.billno, s.billdate, c.custid, i. iitemid, i.price, s.qty from
customer c,sale s item I where c.custid=s.custid and i.iemid=s.itemid);
view created.
……………………………………………………………………………………………
TEXT WIDGET
This is a text widget, which allows you to add text or HTML to your
sidebar. You can use them to display text, links, images, HTML, or a
combination of these. Edit them in the Widget section of
the Customizer.
Advertisements
REPORT THIS AD
SEARCH
Search
Search for:
Create a free website or blog at WordPress.com.
Facebook
Instagram
Close and accept
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy