sql server - SQL SELECT DISTINCT for dynamic data -
need little if possible: got data follows , filtered , inquiryid column trying work inquiry number of booking:
the last column has number of nights in trying calculate using excel 2007.
the column inq_date
booked nights hotel stay , in case , enquiry 2 nights. each booking has amount of lines on equals amount of nights staying for.
a second booking follows:
7 lines - inquiryid = 9501
this booking 7 nights , differs first 1 above of 2 nights.
in column @ end , need calculate nights , on filtered data .
there 2 tables involved :
booking_inquiry booking_inquiry_rooms linked on : inquiryid
so far have:
in sql(which works has specified specific inquiryid)
select distinct count(inquiryid)from dbo.booking_inquiry_rooms inquiryid = '9501'
this returns 7
i know there , need adapt clause , maybe dynamic parameter , cant life of me how...
can me please?
thanks,
matt
select inquiryid, count(*) nights dbo.booking_inquiry_rooms group inquiryid
just use group by...
Comments
Post a Comment