Basically have 2 quaeries. The first one brings back a basic selection between 2 joined tables. The second one groups and counts the first one.
SELECT substr(sfid,1,6) AS test, SFCODE, SVCID, SVCOTY
FROM SVCYAD/SVCFT, SVCYAD/SRVMAST99 WHERE
SFCODE = 'A2 '
SELECT test, SFCODE, SVCOTY, count(svcoty)
FROM
GROUP BY test, SFCODE, SVCOTY
That I need to run as one query. I can only find basic examples of what to do.
I have tried variations of...
SELECT test, SFCODE, SVCOTY, count(svcoty)
FROM (SELECT substr(sfid,1,6) AS test, SFCODE, SVCID, SVCOTY FROM SVCYAD/SVCFT, SVCYAD/SRVMAST99 WHERE
SFCODE = 'A2 ') as bla
GROUP BY test, SFCODE, SVCOTY
I have also tried to group the first query and it gives me an error basically saying that it is to complex.
Trying to run this on AS400/DB2 if that makes a difference.
Thanks
M
SELECT substr(sfid,1,6) AS test, SFCODE, SVCID, SVCOTY
FROM SVCYAD/SVCFT, SVCYAD/SRVMAST99 WHERE
SFCODE = 'A2 '
SELECT test, SFCODE, SVCOTY, count(svcoty)
FROM
GROUP BY test, SFCODE, SVCOTY
That I need to run as one query. I can only find basic examples of what to do.
I have tried variations of...
SELECT test, SFCODE, SVCOTY, count(svcoty)
FROM (SELECT substr(sfid,1,6) AS test, SFCODE, SVCID, SVCOTY FROM SVCYAD/SVCFT, SVCYAD/SRVMAST99 WHERE
SFCODE = 'A2 ') as bla
GROUP BY test, SFCODE, SVCOTY
I have also tried to group the first query and it gives me an error basically saying that it is to complex.
Trying to run this on AS400/DB2 if that makes a difference.
Thanks
M