sql - SQLite: Calculate col based on the result of other Calculated Col -
in sqlite database have table "test" containing integer-typed col "a".
based on col, want calculate 2 more cols, second needs result of first.
so tried following:
select a, a+1 b, b*2 c test
but in sqlite not work:
error: no such column: b
in other dbms seems work, tried similar @ w3schools following query.
select customerid a, a+1 b, b*2 c customers
... , there erevything alright.
is there way achive same in sqlite without sub-selects?
check this link talks limitations of column aliases in mysql. quoting relevant line link:
the clause determines rows should included in group clause, refers alias of column value not known until after rows have been selected, , grouped group by.
i guess, extension, using alias select within same query fail same reason.
instead, try using column names in expressions. way code can work across dbms.
select a, a+1 b, (a+1)*2 c test
Comments
Post a Comment