Again Doubt on Query pls help (Doubt not cleared)
i have to write one query DivisionUnitsYear a 200 2004 a 300 2005 b 500 2004 b 800 2005 b 900 2006 c
Re: Again Doubt on Query pls help (Doubt not cleared)
I think this is what you want to do: SELECT t1.Division,t1.year, t1.units this_year_units, t2.units last_year_units, case when t2.units is null then t1.units else (t1.units-t2.units) end as Difference_Units FROM `narra_table` t1 left join narra_table t2 on (t1.Division=t2.Division) and