Tuesday, January 21, 2020

Sql Server left join with group, group left join


declare @date_from date='01-mar-2020',@date_to date='31-mar-2020'
select
datediff(month,cast(c.conn_date as date),@date_from),
datediff(month,cast(c.conn_date as date),@date_from)*c.cur_tax
,*
from Consumer_Conn c
left join
(bill_det d
join bill_mas m on m.b_code=d.b_code
join
(select dd.cons_code,max(mm.date_to) date_to from bill_mas mm
join bill_det dd on mm.b_code=dd.b_code
group by dd.cons_code)as a on a.date_to=m.date_to and a.cons_code=d.cons_code
) on d.cons_code=c.cons_code



Linq Expression syntax for where condtion in linq

(Expression<Func<T, bool>> filter)