Transfers

/* All transfers and bookings they are assigned to*/


Select T.booking_no     [Code],

       isnull(B.OrganizationV6,'') [Company],

       DATENAME(WEEKDAY,T.ddate) [Out],

       convert(varchar,T.ddate,105)  [Date], 

       dbo.MakeTime(T.del_time_h,t.del_time_m) [Time],

       DATENAME(WEEKDAY,T.rdate) [In],

       convert(varchar,T.rdate,105)  [Date],

       dbo.MakeTime(T.ret_time_h,t.ret_time_m) [Time],

       CASE

         WHEN B.bookingprogressstatus = 0 THEN 'Quote'

         WHEN B.bookingprogressstatus = 1 THEN 'Light Pencil'

         WHEN B.bookingprogressstatus = 2 THEN 'Heavy Pencil'

         WHEN B.bookingprogressstatus = 3 THEN 'Confirmed'

         ELSE 'Cancelled'

       END                AS [Progress Status],

       isnull(T.showName,'') [Showname]

From vwHistBookGrid T

left outer join vwHistBookGrid B on b.booking_no = t.Assigned_to_v61

Where T.booking_no like 'T00%'