0

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

SELECT * 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?

1
  • It's to calculate or calculation and calculated value .... Commented Sep 1, 2011 at 20:59

1 Answer 1

1

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;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.