sql - Joining Two query -
select a.enquiry_id,a.ckeck_in,a.check_out,a.hotel_name,a.meal_plan,a.room_type,a.occupancy_type,a.room_qt,a.adults accomodation a.enquiry_id = 74 select q.enquiry_id,q.start,q1.stay_at quick_plan q,quick_plan q1 q.enquiry_id = 74 , q1.enquiry_id = 74 , q.stay_at = q1.start
result of 1st query is
74 2013-08-03 2013-08-04 ads cp deluxe double 1 2
and result of 2nd query is
74 ahmedabad agra
nw want combine these 2 query result
74 2013-08-03 2013-08-04 ads cp deluxe double 1 2 ahmedabad agra
in case easiest way use ctes won't need modification.
;with firstcte ( select a.enquiry_id, a.ckeck_in, a.check_out, a.hotel_name, a.meal_plan, a.room_type, a.occupancy_type, a.room_qt, a.adults accomodation a.enquiry_id = 74 ), secondcte ( select q.enquiry_id, q.start, q1.stay_at quick_plan q, quick_plan q1 q.enquiry_id = 74 , q1.enquiry_id = 74 , q.stay_at = q1.start ) select * firstcte f join secondcte s on f.enquiry_id = s.enquiry_id
i think proper way be:
select a.enquiry_id, a.ckeck_in, a.check_out, a.hotel_name, a.meal_plan, a.room_type, a.occupancy_type, a.room_qt, a.adults , q.start, q1.stay_at accomodation join quick_plan q on a.enquiry_id = q.enquiry_id join quick_plan q1 on q.enquiry_id = q1.enquiry_id , q.stay_at = q1.start a.enquiry_id = 74
Comments
Post a Comment