That works. Thanks! > From: Pavel Ivanov <paiva...@gmail.com>
> Oops, sorry! I misunderstood what you > need. Try this: > > select id, > case when act_sum = 1 then 'NEW' > when act_sum = 0 then 'CHANGE' > else 'DROP' > end as Action, > net > from > ( > select id, > sum(case when d1='X' then 1 else -1 end) as act_sum, > sum(case when d1='X' then amt else -amt end) as net > from Source > group by id > ) > order by 2 desc; > > > Pavel > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users