Left join a query with a cross apply

Use OUTER APPLY. Also I’m not sure if the ON clause after the OUTER APPLY is really needed. If the invoiceid is the same coming out as going in then probably not.

Select iv.invoiceno, iv.invoiceitem,iv.invoiceno
   from invoice iv
inner join deal d
        on d.dealid=iv.dealid
inner join invoiceitemview ivt
        on iv.invoiceid=ivt.invoiceid and iv.invoiceno=ivt.invoiceno
inner join warehouse w
        on w.locationid=iv.locationid and w.inactive<>'T'
left join category c
        on c.categoryid=ivt.categoryid 
left join ordernoteview n
        on ivt.orderid=n.orderid and n.billing ='T'
OUTER APPLY dbo.funcglforinvoice(iv.invoiceid, null, null) as tot

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)