I have an SQL command in my query in Excel. I'm not sure if this is possible, but can you put 2 commands in 1 query? I have:
我在Excel中的查询中有一个SQL命令。我不确定这是否可行,但你可以在1个查询中输入2个命令吗?我有:
SELECT TALLY_TRAN_MSTR.LOGON_ID, SUM(TALLY_TRAN_MSTR.FULL_PLLT_QTY), TALLY_TRAN_MSTR.SHIFT_DT
FROM WBR_RW.TALLY_TRAN_MSTR
GROUP BY TALLY_TRAN_MSTR.LOGON_ID, TALLY_TRAN_MSTR.SHIFT_DT
and
和
SELECT TALLY_TRAN_MSTR.PRI_GRP_CD
WHERE (TALLY_TRAN_MSTR.PRI_GRP_CD = "PUT")
I got this code to work separately, but I don't know how to combine them. Is there a way to do this?
我让这个代码单独工作,但我不知道如何组合它们。有没有办法做到这一点?
2 个解决方案
#1
0
SELECT TALLY_TRAN_MSTR.LOGON_ID, SUM(TALLY_TRAN_MSTR.FULL_PLLT_QTY), TALLY_TRAN_MSTR.SHIFT_DT, TALLY_TRAN_MSTR.PRI_GRP_CD
FROM WBR_RW.TALLY_TRAN_MSTR
WHERE (TALLY_TRAN_MSTR.PRI_GRP_CD = "PUT")
GROUP BY TALLY_TRAN_MSTR.LOGON_ID, TALLY_TRAN_MSTR.SHIFT_DT, TALLY_TRAN_MSTR.PRI_GRP_CD
You should be able to shorten this to:
你应该可以缩短到:
SELECT LOGON_ID, SUM(FULL_PLLT_QTY), SHIFT_DT, PRI_GRP_CD
FROM TALLY_TRAN_MSTR
WHERE (PRI_GRP_CD = "PUT")
GROUP BY LOGON_ID, SHIFT_DT, PRI_GRP_CD
#2
0
SELECT TALLY_TRAN_MSTR.LOGON_ID, SUM(TALLY_TRAN_MSTR.FULL_PLLT_QTY), TALLY_TRAN_MSTR.SHIFT_DT
FROM WBR_RW.TALLY_TRAN_MSTR
GROUP BY TALLY_TRAN_MSTR.LOGON_ID, TALLY_TRAN_MSTR.SHIFT_DT
HAVING (TALLY_TRAN_MSTR.PRI_GRP_CD = "PUT")
#1
0
SELECT TALLY_TRAN_MSTR.LOGON_ID, SUM(TALLY_TRAN_MSTR.FULL_PLLT_QTY), TALLY_TRAN_MSTR.SHIFT_DT, TALLY_TRAN_MSTR.PRI_GRP_CD
FROM WBR_RW.TALLY_TRAN_MSTR
WHERE (TALLY_TRAN_MSTR.PRI_GRP_CD = "PUT")
GROUP BY TALLY_TRAN_MSTR.LOGON_ID, TALLY_TRAN_MSTR.SHIFT_DT, TALLY_TRAN_MSTR.PRI_GRP_CD
You should be able to shorten this to:
你应该可以缩短到:
SELECT LOGON_ID, SUM(FULL_PLLT_QTY), SHIFT_DT, PRI_GRP_CD
FROM TALLY_TRAN_MSTR
WHERE (PRI_GRP_CD = "PUT")
GROUP BY LOGON_ID, SHIFT_DT, PRI_GRP_CD
#2
0
SELECT TALLY_TRAN_MSTR.LOGON_ID, SUM(TALLY_TRAN_MSTR.FULL_PLLT_QTY), TALLY_TRAN_MSTR.SHIFT_DT
FROM WBR_RW.TALLY_TRAN_MSTR
GROUP BY TALLY_TRAN_MSTR.LOGON_ID, TALLY_TRAN_MSTR.SHIFT_DT
HAVING (TALLY_TRAN_MSTR.PRI_GRP_CD = "PUT")