I need to use a SQL statement that is bound to a Gridview & needs to be something like
SELECT * from Table Sum(Column1) AS S00, (S00/CONSTANT) AS C01 or
SEL开发者_开发知识库ECT * from Table Sum(Column1) AS S00, Sum(Column1) / CONSTANT AS C01
CONSTANT will be a value passed to the query as a session variable.
i.e the 2nd column of the Gridview is calculated from the result of 1st calculation.
What will be the best way to achieve this?
You'll need to repeat the expression, or use a subquery e.g.
SELECT *, C01 = (S00/Constant)
FROM
(
SELECT S00 = SUM(Column1)
FROM table
) AS x;
精彩评论