Thanks, Igor & Michael - your help is much appreciated. Cheers Kai
On Mon, Mar 21, 2011 at 4:47 AM, Igor Tandetnik <[email protected]> wrote: > Kai Peters <[email protected]> wrote: >> given a table with two columns (SaleDate, SaleVolume) is it possible in one >> query to obtain >> the following three column result set: >> >> SalesCurrentYear, SalesLastYEar, SalesAllyears > > select > sum(SaleVolume * (SaleDate >= StartOfCurYear)) SalesCurrentYear, > sum(SaleVolume * (StartOfLastYear <= SaleDate and SaleDate < > StartOfCurYear)) SalesLastYear, > sum(SaleVolume) SalesAllYears > from Sales, > (select > date('now', 'start of year') StartOfCurYear, > date('now', 'start of year', '-1 years') StartOfLastYear); > > -- > Igor Tandetnik > > _______________________________________________ > sqlite-users mailing list > [email protected] > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

