Jump to content
Sign in to follow this  
Erik Luis

Utilização de subquerys

Recommended Posts

Boa Tarde,

Estou com duvidas quanto a geração de uma query, pois as pesquisas que estou realizando são extraídas através de varias tabelas para extrair informações de um determinado ID.

No caso eu gostaria de chamar 3 querys diferentes inserindo o resultado de sua query como variavel. Segue o que estou fazendo:

SELECT query1.VALOR1 , query2.VALOR2 [...]
FROM CYCLE
( SELECT CYCLE.CY_ASSIGN_RCYC AS CICLO_ID, COUNT(DESSTEPS.DS_ID) AS VALOR1
FROM CYCLE
LEFT JOIN TESTCYCL ON CYCLE.CY_ASSIGN_RCYC = TESTCYCL.TC_ASSIGN_RCYC
LEFT JOIN TEST ON TESTCYCL.TC_TEST_ID = TEST.TS_TEST_ID
LEFT JOIN DESSTEPS ON TEST.TS_TEST_ID = DESSTEPS.DS_TEST_ID
WHERE DESSTEPS.DS_LINK_TEST <> 0
GROUP BY CYCLE.CY_ASSIGN_RCYC
) query1
( SELECT CYCLE.CY_ASSIGN_RCYC AS CICLO_ID, COUNT(DESSTEPS.DS_ID) AS VALOR1
FROM CYCLE
LEFT JOIN TESTCYCL ON CYCLE.CY_ASSIGN_RCYC = TESTCYCL.TC_ASSIGN_RCYC
LEFT JOIN TEST ON TESTCYCL.TC_TEST_ID = TEST.TS_TEST_ID
LEFT JOIN DESSTEPS ON TEST.TS_TEST_ID = DESSTEPS.DS_TEST_ID
WHERE DESSTEPS.DS_LINK_TEST <> 0
GROUP BY CYCLE.CY_ASSIGN_RCYC
) query2
...
WHERE CYCLE.CY_ASSIGN_RCYC = @projeto@
O que eu quero fazer, é apresentar um relatório que exiba o VALOR das querys que eu definir.
Poderiam me auxiliar por gentileza.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

Ao usar o fórum, você concorda com nossos Terms of Use.