2010-12-15 3 views
0

오라클이 아닌 SQL Server를 알고 있기 때문에 SQL Server 언어로 말할 것입니다.오라클에 처음으로 테이블을 조인하여 결과 세트에 필드 값을 가져와야합니다.

나는 아래의 필드를 선택해야합니다. 나는 그 중 2 개를 제외하고 모두 BUG 테이블에서 찾았습니다. 다른 두 테이블 내 Oracle SQL에 들어가는 방법에 대한 명확하지 않은 다른 테이블에 있습니다.

나는 또한 내게 더 의미있는 필드 이름과 내 indecently 내 SQL 테이블에있는 필드 이름으로 dame 오라클에 정의 된 필드 이름을 변환 싶어요. (이것은 Oracle 추출물/sql2005 삽입 작업의 일부입니다.)이 작업은 oricalafied가되어야 할 수도 있습니다. im을 SQL 방식으로 작성하고 작업 할 것으로 기대합니다 ... 알려주십시오.

BG_SUBJECT 필드 AL_ITEM_ID가 기본 키입니다 ALL_LISTS 테이블의 일부입니다 :

내 SQL은 너무 멀리있는 난에 가입해야 2 개 필드 자리 표시 자 ''추가.

DetectedInRelease는 REL_ASID가 기본 키인 RELEASES 테이블의 REL_NAME 필드입니다.

SELECT 
bg_user_56 AS Project, 
bg_user_60 AS SubSystem, 
BG_USER_81 AS AssignedToUserName, 
bg_responsible AS AssignedTo, 
bg_status AS Status, 
BG_USER_15 AS BusinessFunction, 
bg_detection_date AS DetectedOnDate, 
BG_SEVERITY AS BusinessSeverity, 
bg_user_36 AS TestingSeverity, 
bg_bug_id AS DefectID, 
Bg_User_09 AS EstFixedDate, 
bg_user_25 AS EstReadyForRetest, 
BG_DESCIPTION AS description, 
BG_USER_03 AS DetectedInDeploymentEvent, 
'' AS DetectedInRelease,--- ??? not in bug table !!!! 
BG_USER_47 AS FunctionalAreaWorkstream, 
BG_USER_19 AS PlannedFixInDeploymentEvent, 
BG_USER_55 AS PlannedFixInRelease, 
BG_USER_57 AS PTMTestManager, 
Bg_User_58 AS RemediatingCTOName, 
'' AS Subject,--- ??? not in bug table !!! 
bg_summary AS Summary, 
bg_user_80 AS MLTestEnvironment, 
GETDATE() AS LoadDateTime, 
bg_user_12 AS Deferred 
FROM tascs_ml_bac_transition_db.BUG 
+0

? 조인은 Oracle에서 SQL Server와 거의 동일해야합니다. – FrustratedWithFormsDesigner

+0

누락 필드 2 개를 제외하고 쿼리가 효과적입니다. BUG 테이블과 다른 두 테이블 사이에 조인하는 방법을 알고 있다면 SQLServer에서 사용했던 것처럼 INNER JOIN 또는 LEFT OUTER JOIN을 추가하면됩니다. – LaGrandMere

답변

0

쿼리 구문이되어이 같은, GETDATE 그러나 SYSDATE 할 필요는 샘플 내부 조인 포함 당신이 시도하고 왜 (어떤 오류 메시지가) 실패 했는가

SELECT 
     BUG.bg_user_56   AS Project     , 
     BUG.bg_user_60  AS SubSystem     , 
     BUG.BG_USER_81  AS AssignedToUserName   , 
     BUG.bg_responsible AS AssignedTo     , 
     BUG.bg_status   AS Status      , 
     BUG.BG_USER_15  AS BusinessFunction   , 
     BUG.bg_detection_date AS DetectedOnDate    , 
     BUG.BG_SEVERITY  AS BusinessSeverity   , 
     BUG.bg_user_36  AS TestingSeverity   , 
     BUG.bg_bug_id   AS DefectID     , 
     BUG.Bg_User_09  AS EstFixedDate    , 
     BUG.bg_user_25  AS EstReadyForRetest   , 
     BUG.BG_DESCIPTION  AS description    , 
     BUG.BG_USER_03  AS DetectedInDeploymentEvent , 
     REL.REL_NAME   AS DetectedInRelease   , --- ??? not in bug table !!!! 
     BUG.BG_USER_47  AS FunctionalAreaWorkstream , 
     BUG.BG_USER_19  AS PlannedFixInDeploymentEvent, 
     BUG.BG_USER_55  AS PlannedFixInRelease  , 
     BUG.BG_USER_57  AS PTMTestManager    , 
     BUG.Bg_User_58  AS RemediatingCTOName   , 
     al.BG_SUBJECT   AS Subject     , --- ??? not in bug table !!! 
     BUG.bg_summary  AS Summary     , 
     BUG.bg_user_80  AS MLTestEnvironment   , 
     sysdate    AS LoadDateTime    , --changed to sysdate 
     BUG.bg_user_12  AS Deferred 
FROM 
     tascs_ml_bac_transition_db.BUG BUG 
     INNER JOIN 
     ALL_LISTS al 
      ON BUG.AL_ITEM_ID = al.AL_ITEM_ID --THIS ASSUMES AL_ITEM_ID IS COMMON FIELD 
     INNER JOIN 
     RELEASES REL 
      ON BUG.REL_ID  = REL.REL_ID --THIS ASSUMES REL_ID IS COMMON FIELD 
0

나는이에 자상을거야 :

SELECT 
bg_user_56 AS Project, 
bg_user_60 AS SubSystem, 
BG_USER_81 AS AssignedToUserName, 
bg_responsible AS AssignedTo, 
bg_status AS Status, 
BG_USER_15 AS BusinessFunction, 
bg_detection_date AS DetectedOnDate, 
BG_SEVERITY AS BusinessSeverity, 
bg_user_36 AS TestingSeverity, 
bg_bug_id AS DefectID, 
Bg_User_09 AS EstFixedDate, 
bg_user_25 AS EstReadyForRetest, 
BG_DESCIPTION AS description, 
BG_USER_03 AS DetectedInDeploymentEvent, 
rel.BG_DetectedInRelease AS DetectedInRelease,--- ??? not in bug table !!!! 
BG_USER_47 AS FunctionalAreaWorkstream, 
BG_USER_19 AS PlannedFixInDeploymentEvent, 
BG_USER_55 AS PlannedFixInRelease, 
BG_USER_57 AS PTMTestManager, 
Bg_User_58 AS RemediatingCTOName, 
al.BG_SUBJECT AS Subject,--- ??? not in bug table !!! 
bg_summary AS Summary, 
bg_user_80 AS MLTestEnvironment, 
GETDATE() AS LoadDateTime, 
bg_user_12 AS Deferred 
FROM tascs_ml_bac_transition_db.BUG B, ALL_LISTS al, releases rel 
WHERE al.al_item_id = b.al_item_id and rel.rel_id = b.rel_id; 

내가이 테이블의 전체 DDL을 가지고 있지 않기 때문에이 작동하는지 짐작하기 어렵다, 그러나 이것은 내 당신이 준 것을 바탕으로 최고의 추측. 나는 BUG가 당신이 가입해야하는 것과 같은 이름을 가진 필드를 가지고 있다고 가정했다. 이는 유효하지 않을 수도 있으며 명확하게 설명해주십시오.

원하는 경우 INNER JOIN ON 구문을 사용할 수도 있습니다. 효과적으로

관련 문제