0

我有 3 张桌子:

REPOTRANSSMISSIONTABLE 列是

REPO_TRANSMISSION_ID,
G3_SESSION_ID,
CLIENT_NM,
ASSESSMENT_SESSION_ID,
PACKAGE_SESSION_ID,
TEST_SESSION_ID,
SCORE_SESSION_ID,
REPO_TRANSMISSION_STATE_CD,
REPO_TRANSMISSION_DATA_TX,
REPO_TRANSMISSION_LEVEL_CD,
CREATE_DT,
LAST_MODIFIED_DT. 

这里REPO_TRANSMISSION_ID是主键, REPO_TRANSMISSION_STATE_CD是外键

第二个表REPO_ TRANSSMISSION_REQ_LOG列是

REPO_TRANSMISSION_REQ_LOG_ID
REPO_TRANSMISSION_ID
REQUEST_TX
RESPONSE_TX
ERROR_TX
CREATE_DT
LAST_MODIFIED_DT 

这里PK_REPO_TRANSMISSION_REQ_LOG是主键,REPO_TRANSMISSION_ID是外键

第三个表REPO TRANSSMISSION STATE列是

REPO_TRANSMISSION_STATE_CD
REPO_TRANSMISSION_STATE_DS
CREATE_DT
LAST_MODIFIED_DT
and 
REPO_TRANSSMISSION_STATE_CD values are TRANS_RESP,
RECON_REQ,
RECON_ERR,
RECON_RETRY,
RECON_RESP 

PK_REPO_TRANSMISSION_STATE_cd是主键

repo_transsmission_Id当值高于 4 时,我必须检索它repotransmission_state_cd,并且我必须加入第一个和第二个表。

我将如何编写 sql 查询?

4

1 回答 1

0

您是否只想查看查询如何为您提供所需的结果?

它会是这样的:

SELECT tr.repo_transmission_id
  FROM REPOTRANSSMISSION tr
    JOIN REPO_TRANSSMISSION_REQ_LOG lg ON (tr.REPO_TRANSMISSION_ID = lg.REPO_TRANSMISSION_ID)
WHERE tr.REPO_TRANSMISSION_STATE_CD > 4;
于 2013-10-03T10:42:46.603 回答