The questions can come in any order, so make sure you are selecting right option for all questions.
1. Write a query to display the person_name and the contact_number from travel_card table of every person whose destination station is on the route 'North East line' with the payment more than 25. Display the records in ascending order based on person name.select t.person_name, t.contact_number from travel_card t inner join travel_payment tp on t.id = tp.travel_card_id inner join station s on tp.exit_station_id = s.id where s.id in ( select station_id from station_route where route_id in ( select id from route where route_name = 'North East line' ) ) and tp.amount>25 order by t.person_name;
select s.name, s.locality from station s inner join train_schedule ts on s.id = ts.station_id where ts.scheduled_time like '21-DEC-17%' and s.id in ( select station_id from station_route where route_id in ( select id from route where route_name = 'Circle line') ) order by s.name;
select person_name,contact_number,balance from travel_card where id = ( select travel_card_id from travel_payment where amount = ( select min(amount) from travel_payment) ) order by person_name desc;
select t.person_name,t.contact_number,t.balance,p.entry_time,p.exit_time from travel_card t,travel_payment p where t.id = p.travel_card_id and t.balance in ( select max(balance) from travel_card where balance not in ( select max(balance) from travel_card))
Select tc.person_name, tc.contact_number, tc.balance from travel_card tc join ( select travel_card_id, count(*) as travel_count from travel_payment group by travel_card_id) tp on tc.id = tp.travel_card_id where tp.travel_count = ( select max(travel_count) from ( select count(*) as travel_count from travel_payment group by travel_card_id) ) order by tc.person_name desc;