On Sat, Nov 14, 2009 at 1:58 PM, Peter Haworth <p...@mollysrevenge.com> wrote:
> I'm trying to get a SELECT statement in the following general form to work:
>
> SELECT CASE WHEN <condition> THEN <calculation> ELSE <calculation>  END AS
> CalcA, sum(CalcA) AS CalcATotal ....
>
> I get an error "no such column" referring to CalcA when used in the sum
> function.  I'm trying to get total of all the values of CalcA across all the
> selected rows.  Is there a way to do this?
>

Try

SELECT sum(CalcA) AS CalcATotal
FROM (
  SELECT CASE WHEN <condition> THEN <calculation> ELSE <calculation>
END AS CalcA
  FROM table
  WHERE ...
)


> Pete Haworth
>
>
>
>
>
>
>
>
> http://www.mollysrevenge.com
> http://www.sonicbids.com/MollysRevenge
> http://www.myspace.com/mollysrevengeband
>
>
>
>
>
>
>
>


-- 
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
-----------------------------------------------------------------------
Assertions are politics; backing up assertions with evidence is science
=======================================================================
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to