0% found this document useful (0 votes)
14 views12 pages

SQL Dumps

Uploaded by

20eg105715
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)
14 views12 pages

SQL Dumps

Uploaded by

20eg105715
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/ 12

w-- 1.

Preponed Departure Date

select booking_id, flight_name, subdate(flight_date,5) as PREPONED_DEPARTURE_DATE

from flight_details

where flight_source != "Miami"

order by booking_id desc;

-- 2. Customer Purchase Details

select cd.customer_id,cd.customer_name,cd.phone_no,pd.purchase_date

from customer_details cd

join purchase_details pd on cd.customer_id=pd.customer_id

where cd.city != 'Delhi'

order by cd.customer_id desc;

-- 3. Customer With Email

select c.cust_name,o.order_id,o.order_date

from customers c

join orders o on c.cust_id=o.cust_id

where c.email_id like "%@gmail.com"

order by o.order_id desc;

-- 4. Boat With Same Capacity

select b1.boat_id,b1.boat_name

from boat_details b1

join boat_details b2 on b1.seat_capacity=b2.seat_capacity

where b1.boat_id!=b2.boat_id
order by b1.boat_name;

-- Q5 Product Category Details

select distinct p.productname,p.category

from products p

join feedback f on p.product_id=f.product_id

where f.rating_value<3

order by p.productname;

-- Q6 Member and product details

select m.fullname,m.email,m.member_id,f.product_id

from members m

join feedback f on m.member_id=f.member_id

where month(m.date_of_birth) in (1,12)

order by m.fullname desc;

-- Q7 Date Of Delivery

select cust_name,email_id,coalesce(address,phone_no) as Contact_Info

from customers

where cust_id in (

select cust_id

from orders

where order_date!=delivery_date

order by cust_name;
-- Q8 Movie And Theatre Details

select mm.movie_name,sm.theatre_id,mm.duration

from movie_master mm

join screening_master sm on mm.movie_id=sm.movie_id

where lower(mm.language) != 'hindi'

order by mm.movie_name desc;

-- Q9 Chicago Flights

select f1.flight_name,f1.flight_source

from flight_details f1

join flight_details f2 on f1.flight_destination=f2.flight_destination

where f1.flight_source!=f2.flight_source

order by f1.destination,f1.flight_name;

-- Q10 Member Details Based On Condition

select m.fullname

from members m

join feedback f on m.member_id=f.member_id

where m.email like "%@gmail.com" and address = 'Bangalore' and f.rating_value>4

order by m.fullname desc;

-- Q11 Specific Patient Address

select p.p_first_name,a.app_reason,a.app_time,b.bill_amount

from patient p
join appointment a on p.patient_id=a.patient_id

join bill b on a.app_number=b.app_number

where p.address like "%Avenue%"

order by a.app_time;

-- Q12 Ordered Month

select distinct c.cust_name,c.email_id,c.phone_no

from customers c

join orders o on c.cust_id=o.cust_id

where month(o.order_date) between 2 and 8

order by c.cust_name;

-- Q13 Seat Count

select b.boat_id,b.boat_name,b.boat_type,round((b.seat_capacity*0.75),2) as SEAT_COUNT

from boat_details b

join ride_details r on b.boat_id=r.boat_id

where year(r.dot)=2000

order by b.boat_name desc;

-- Q14 Movie Details

select mm.movie_id,mm.movie_name,sm.show_time

from movie_master mm

join screening_master sm on mm.movie_id=sm.movie_id

where lower(language)='tamil' and certification!='A'

order by sm.screening_id desc;


-- Q15 Bill Payment

select p.patient_id,p.p_first_name,p.city,p.p_age

from patient p

join appointment a on p.patient_id=a.patient_id

join bill b on a.app_number=b.app_number

left join payment pt on b.bill_number=pt.bill_number

where pt.payment_id is null

order by p.age;

-- Q16 Policy Enrolled Customers with gmail user

select c.customer_id,c.customer_name,p.policy_id,p.total_amount,p.no_of_year

from customer c

join policyenrollment p on c.customer_id=p.customer_id

where c.email_id like "%@gmail.com"

order by p.enrollment_id desc;

-- Q17 Male policy Enrollments

select c.customer_id,c.customer_name,p.policy_id

from customer c

join policyenrollment p on c.customer_id=p.customer_id

where c.gender = 'M'

order by p.enrollment_id desc;

-- Q18 Most Number of Years


select policy_id,policy_name

from policy

where policy_id in (

select policy_id

from policyenrollment

group by policy_id

having sum(no_of_year) =(

select max(m) from (

select sum(no_of_years) m

from policyenrollment

group by policy_id

)s

order by policy_name

-- Q19 Customer and booking details

select c.customer_name,b.total_amount

from customer_master c

join booking_details b on c.customer_id=b.customer_id

where year(b.booking_date)=2018

order by b.booking_id desc;

-- Q20 Patient from same city


select p1.p_first_name,p1.city

from patient p1

join patient p2 on p1.city=p2.city

where p1.patient_id!=p2.patient_id

order by p1.city;

-- Q21 Recent Subscriber

select customer_name

from customer

where phone_number=(

select phone_number

from subscription

where recharge_date =(

select max(recharge_date)

from subscription

order by customer_name desc;

-- Q22 Customer details based on gender

select
customer_id,customer_name,date_of_birth,mariral_status,gender,gurdian_name,contact_no,ema
il_id

from customer_personal_info
where upper(gender)='M' and upper(marital_status)='MARRIED'

order by customer_id;

-- Q23 Passcode generation

select c.customer_id,a.account_no,concat(right(c.customer_id,3),right(a.account_no,4))

as PASSCODE

from customer_personal_info c

join account_info a on c.customer_id=a.customer_id

order by c.customer_id;

-- Q24 Customer Details Based on name

select customer_id,customer_name,date_of_birth,gurdian_name

from customer_personal_info

where customer_name like "J%"

order by customer_id;

-- Q25 Customer details based on name starting with 'J'

select
c.customer_id,c.customer_name,a.account_no,a.account_type,b.bank_name,b.ifsc_code,a.initial
_deposite,

case

when upper(a.account_type)='SAVINGS' then round((a.interest*1.1),2)

else a.interest

end NEW_INTEREST

from customer_personal_info c

join account_info a on c.customer_id=a.customer_id


join bank_info b on a.ifsc_code=b.ifsc_code

order by c.customer_id;

-- Q26 Customer details based on tax

select c.customer_id,c.customer_name,a.account_no,a.initial_deposite,

case

when a.initial_deposite then '0%'

when a.initial_deposite<=10000 then '3%'

when a.initial_deposite>10000 and a.initial_deposite<20000 then '5%'

when a.initial_deposite>=20000 and a.initial_deposite<=30000 then '7%'

when a.initial_deposite>30000 then '10%'

end taxPercentage

from customer_personal_info c

join account_info a on c.customer_id=a.customer_id

join bank_info b on a.ifsc_code=b.ifsc_code

order by c.customer_id;

-- Q27 Customer Account Details.

select a.customer_id,a.account_type,a.account_number,b.bank_name

from account_info a

join bank_info b on a.ifsc_code=b.ifsc_code

order by a.customer_id;

-- 28 Customer interest details based on friend reference

select cri.customer_id,cpi.customer_name,cpi.guardian_name,cri.reference_acc_name
from customer_reference_info cri

join customer_personal_info cpi on cri.customer_id=cpi.customer_id

where upper(cri.relation)='FRIEND'

order by cri.customer_id;

-- Q29 Customer interest details in specified format

select customer_id,account_no,concat('$',round(interest,0)) as INTEREST_AMT

from account_info

order by interest,customer_id;

-- Q30 Customer Details based on activation date.

select
cpi.customer_id,cpi.customer_name,a.account_no,a.account_type,a.activation_date,b.bank_nam
e

from customer_personal_info cpi

join account_info a on cpi.customer_id=a.customer_id

join bank_info b on a.ifsc_code=b.ifsc_code

where a.activation_date='2022-04-10'

order by cpi.customer_id;

-- Q31 Customer details based on interest and deposite amount

select
a.acount_no,cpi.customer_id,cpi.customer_name,b.bank_name,b.branch_name,b.ifsc_code,cpi.c
itizenship,

a.interest,a.initial_deposit

from customer_personal_info cpi

join account_info a on cpi.customer_id=a.customer_id


join bank_info b on a.ifsc_code=b.ifsc_code

order by cpi.customer_id;

-- Q32 Customer details based on identification document

select
cpi.customer_id,cpi.customer_name,cpi.date_of_birth,cpi.guardian_name,cpi.cintact_no,cpi.mail
_id,

cri.reference_acc_name

from customer_personal_info cpi

join customer_reference_info cri on cpi.customer_id=cri.customer_id

where upper(cpi.identification_doc_type)='PASSPORT'

order by cpi.customer_id;

-- Q33 Customer details who all having account in bank

select cpi.customer_id,cpi.customer_name,a.account_no,a.account_type,b.bank_name

from customer_personal_info cpi

join account_info a on cpi.customer_id=a.customer_id

join bank_info b on a.ifsc_code=b.ifsc_code

order by cpi.customer_id;

-- Q34 Customer details based on reference string

select customer_id,customer_name,gender,marital_status,

concat(customer_name,'_',gender,'_',marital_status) as UNIQUE_REF_STRING

from customer_personal_info

order by customer_id desc;


-- Q35 Customer details based on deposit amount range

select account_no,customer_id,registration_date,intial_deposit

from account_info

where intial_deposit between 15000 and 25000

order by account_no;

-- Q36 Customer account details based on account type

select

from customer_personal_info cpi

join account_info a on cpi.customer_id=a.customer_id

join bank_info b on a.ifsc_code=b.ifsc_code

select customer_id

from account_info

group by customer_id,account_type

having Upper(account_type) = 'SAVINGS'

You might also like