H
Hyko
Hello,
is it possible to include the result of a subquery in a GROUP BY clause?
I tried the following code but it always leads to a syntax error...
SELECT sfc.field1, sfc.field2, (SELECT SUM(svr.field8) FROM svr WHERE
(svr.field9<=sfc.field3 AND ...)) as thesubq, SUM(sfc.field4)
FROM sfc
WHERE ...
GROUP BY sfc.field1, sfc.field2, (SELECT SUM(svr.field8) WHERE
(svr.field9<=sfc.field3 AND ...))
And the following does not work as well:
GROUP BY sfc.field1, sfc.field2, thesubq
If I do not try to group the subquery at all access starts to claim that
svr.field9 is not included in the aggregation function... If include these
fields it leads to wrong results...
Do you have any idea except splitting the query? The original query is much
more complex and it would be great to be able to handle it with one
SQL-command from ASP.
Thanks in advance for any hints.
Best,
Hyko
is it possible to include the result of a subquery in a GROUP BY clause?
I tried the following code but it always leads to a syntax error...
SELECT sfc.field1, sfc.field2, (SELECT SUM(svr.field8) FROM svr WHERE
(svr.field9<=sfc.field3 AND ...)) as thesubq, SUM(sfc.field4)
FROM sfc
WHERE ...
GROUP BY sfc.field1, sfc.field2, (SELECT SUM(svr.field8) WHERE
(svr.field9<=sfc.field3 AND ...))
And the following does not work as well:
GROUP BY sfc.field1, sfc.field2, thesubq
If I do not try to group the subquery at all access starts to claim that
svr.field9 is not included in the aggregation function... If include these
fields it leads to wrong results...
Do you have any idea except splitting the query? The original query is much
more complex and it would be great to be able to handle it with one
SQL-command from ASP.
Thanks in advance for any hints.
Best,
Hyko