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

RDBMS Codes

Uploaded by

riyaaam28
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

RDBMS Codes

Uploaded by

riyaaam28
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Details Based on discount and booking date:

SELECT BOOKING_DETAILS.BOOKING_ID, CUSTOMER_MASTER.CUSTOMER_NAME,


CUSTOMER_MASTER.PHONE_NO

FROM BOOKING_DETAILS INNER JOIN CUSTOMER_MASTER

ON BOOKING_DETAILS.CUSTOMER_ID=CUSTOMER_MASTER.CUSTOMER_ID

WHERE DISCOUNT_COUPOUN='dc02' AND BOOKING_DATE='18-APR-20'

ORDER BY BOOKING_DETAILS.BOOKING_ID;

Hindi Movie Details:

SELECT MOVIE_ID, MOVIE_NAME, DIRECTOR_NAME, CERTIFICATION

FROM MOVIE_MASTER

WHERE LANGUAGE='Hindi' AND DURATION<150

ORDER BY MOVIE_ID;

COURSE DETAILS:

SELECT CourseName,Fees,Fees*1.1

AS NEW_FEES

FROM Course

ORDER BY CourseName;

Student Details:

SELECT distinct s.FirstName,s.City FROM student s

JOIN registration r ON s.StudId=r.StudId WHERE

r.DOJ='10-MAR-2018' ORDER BY FirstName;


2.1 March Month Booking Details:

select c.customer_id, c.customer_name, m.movie_id, m.movie_name, b.booking_id, s.screening_id

from customer_master c join booking_Details b

on c.customer_id=b.customer_id

join screening_master s

on b.screening_id=s.screening_id

join movie_master m

on s.movie_id=m.movie_id

where b.booking_date like '%MAR%'

order by 1;

2.2 Customer Details with Second Highest total amount paid:

select b.total_amount_paid, c.customer_name

from customer_master c

join booking_details b on c.customer_id=b.customer_id

where b.total_amount_paid=(select max(total_amount_paid) from booking_details where


total_amount_paid<(select max(total_amount_paid) from booking_details))

order by customer_name;

1.1 Car Rental for maximum number of day's:

select r.cust_id, cust_name,r.car_id, car_name, (return_date-pickup_date) as

maximum_rental_days from cars c, rentals r, customers d where c.car_id=r.car_id and

d.cust_id=r.cust_id and (return_date-pickup_date) = (select max(return_date-pickup_date) from rentals)

order by r.cust_id;
1.2 Rental Offer:

select rental_id,r.car_id,car_name,car_type,fare_amount,

case

when car_type='Hatchback' THEN fare_amount*0.98

when car_type='Sedan' THEN fare_amount*0.97

when car_type='MPV' THEN fare_amount*0.96

when car_type='SUV' THEN fare_amount*0.95

END AS NEW_FARE_AMOUNT

FROM CARS C,RENTALS R WHERE C.car_id = R.car_id

ORDER BY rental_id;

Employe date of joining:

Select Emp_id,Emp_name, Department_id,DOJ

From Emp_id WHERE Address='Chennai' and TO_CHAR(DOJ,'YYYY')=2018

ORDER BY Emp_id;

Sick leave:

Select e.emp_id,emp_name,department _id,count(leave_avail_id) as TOTAL_LEAVE

from employees e,leave_avail_details l

where e.emp_id=l.emp_id and UPPER(leave_type)='SICK'

order by emp_id;

Details of employee who are:

select i.issue_id,i.employee_id,e.employee_name,i.issue_date,i.return_date

from employee_issue_details i join employee_master e on

i.employee_id=e.employee_id

order by i.issue_id;
Employee details based on address:

select employee_id, employee_name,designation,date_of_joining

from employee_master

where Department='HR'

order by 1;

select customer_name,total_amount_paid

from Customer_master JOIN Booking_details using (customer_id)

where total_amount_paid < (select max(total_amount_paid) from booking_details

where total_amount_paid < (select max(total_amount_paid) from booking_details))

order by customer_name;

select booking_id,user_id,booking_date,driver_name,booking_type

from booking_details b,driver_details d

where b.driver_id=d.driver_id and fare_amount<1000

order by booking_id;

Booking details based on booking type and fare:

select b.booking_id, u.user_id, b.booking_date, fare_amount

from booking_details b join user_details u

on u.user_id=b.user_id

where lower(booking_type)='outstation' and b.fare_amount<4000

order by b.booking_id;
Driver booking details:

select b.booking_date, d.driver_id, d.driver_name, b.booking_type

from booking_details b join driver_details d

on b.driver_id=d.driver_id

where b.booking_date like '%-18' and d.driver_rating=5

order by d.driver_id;

HatchBack:

select c.car_id, c.car_name, o.owner_id, o.owner_name

from cars c join owners o on c.owner_id=o.owner_id

where Inticap(car_type)='Hatchback'

order by1;

Car driven KM Rental details:

select rental_id, customer_id, car_id, km_driven, fare_amount

from rentals

where (return_date-picjup_date)>1

order by 1;

Branch details:

select b.branch_id, b.branch_location ,b.contact_no, from branch b

join courier on b.branch_id=c.branch_id

where booking_date IN('10-FEB-12','06-MAR-12')

order bt b.branch_id;
Courier status based on date:

select status, count(s.courier_id) as courier_count

from courier_status s inner join courier c

on s.courier_id=c.courier_id where booking_date='05-MAR-12'

group by status order by status:

Policy details:

select policy_id, policy_name, rate_of_interest from policy

where minimum_policy_amount<3000 and bonus_interest_percentage>85

order bypolicy_id;

You might also like