Den 22.01.2016 11:51, skrev Luigi Siciliano [email protected] [firebird-support]: > How can I do this query: > > Select > A, > B, > SUM(A + B) as C, > C * A as D ----->>>>> FB result on "C not Exists" error! > from > table > group by > A, > B > > Of course, I can do this: "SUM(A + B) * A as D" to perform my query but, > I wish to learn if is possible the other one (C * A as D) > > Thanks. WITH TMP(A, B, C) AS (SELECT A, B, SUM(A+B) FROM TABLE GROUP BY A, B) SELECT A, B, C, C*A as D FROM TMP
Note that with two identical rows A B 2 2 2 2 The result will be A B C D 2 2 8 16 HTH, Set ------------------------------------ ------------------------------------ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Visit http://www.firebirdsql.org and click the Documentation item on the main (top) menu. Try FAQ and other links from the left-side menu there. Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ------------------------------------ Yahoo Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/firebird-support/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/firebird-support/join (Yahoo! ID required) <*> To change settings via email: [email protected] [email protected] <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo Groups is subject to: https://info.yahoo.com/legal/us/yahoo/utos/terms/
