i have two tables tourist(touristid,touristname,city), bookings(bookingid,touristid,bookingamount)
i need the touristid,touristname,city of tourist who have paid the maximum amount in a single booking
i have two tables tourist(touristid,touristname,city), bookings(bookingid,touristid,bookingamount)
i need the touristid,touristname,city of tourist who have paid the maximum amount in a single booking
/* try this it will work */
select * from tourist
create table tourist (touristid int,touristname varchar(100),city varchar(10))
insert into tourist values (1,'Rajini','warangal'),(2,'magi','hyderabad'),(3,'srikanth','kamam'),(4,'A','hyderabad')
create table bookings(bookingid int,touristid int ,bookingamount int )
insert into bookings values (101,1,199),(102,4,1000),(103,1,299),(104,2,399)
select * from tourist
select * from bookings
select a.touristid,a.touristname,a.city,b.bookingamount as amount
from tourist a join bookings b on a.touristid=b.touristid
and b.bookingamount =(select max(bookingamount) from bookings )