crogers111
Technical User
CR XI
SQL
I have a report that works fine but I need to add it as a subreport to another report and I'm trying to see if I can optimize it.
There are 2 tables in 2 separate databases needed for this subreport..both DBs are on the same server.
Table1 = HC.Data
Table2 = Claims.Claim Header
Currently as a standalon report, I'm using a command for the first DB and am connecting directly to the Claims DB for the 2nd connection and have linked the 2 tables in CR Database Expert and all works but just a bit slow.
Command for Table1:
SELECT VenGroupNumber, CheckDate, ClaimNumber, Vendor, FromDate, DateReceived, EntryDate, ReplacedClaim, ReversalFlag
FROM dbo.Data AS Data
WHERE (VenGroupNumber = '{?GroupNum}') AND (Vendor = 'BRMS') AND (CheckDate >={?PaidFrom}) AND
(CheckDate <= {?PaidTo}) AND (ReversalFlag = 'N') AND (ReplacedClaim IS NULL OR ReplacedClaim = '0')
SQL for Table2:
SELECT "Claim_Header"."holdReason", "Claim_Header"."ClaimNumTxt", "Claim_Header"."Group #"
FROM "Claims"."dbo"."Claim Header" "Claim_Header"
Currently the report is linked via a LOJ on 2 fields:
Data.VenGroupNumber --> Claim_Header.Group #
Data.ClaimNumber --> Claim_Header.ClaimNumTxt
I guess what I'm trying to do is mimic and optimize the joins that I currently have between the command and the table but have only 1 'connection' or command... wondering if this can be accomplished in a single command or other method ?
I've read a lot of examples that incuded using a UNION but it sounds like each query needs to have the same number of fields and data types to use this.
SQL
I have a report that works fine but I need to add it as a subreport to another report and I'm trying to see if I can optimize it.
There are 2 tables in 2 separate databases needed for this subreport..both DBs are on the same server.
Table1 = HC.Data
Table2 = Claims.Claim Header
Currently as a standalon report, I'm using a command for the first DB and am connecting directly to the Claims DB for the 2nd connection and have linked the 2 tables in CR Database Expert and all works but just a bit slow.
Command for Table1:
SELECT VenGroupNumber, CheckDate, ClaimNumber, Vendor, FromDate, DateReceived, EntryDate, ReplacedClaim, ReversalFlag
FROM dbo.Data AS Data
WHERE (VenGroupNumber = '{?GroupNum}') AND (Vendor = 'BRMS') AND (CheckDate >={?PaidFrom}) AND
(CheckDate <= {?PaidTo}) AND (ReversalFlag = 'N') AND (ReplacedClaim IS NULL OR ReplacedClaim = '0')
SQL for Table2:
SELECT "Claim_Header"."holdReason", "Claim_Header"."ClaimNumTxt", "Claim_Header"."Group #"
FROM "Claims"."dbo"."Claim Header" "Claim_Header"
Currently the report is linked via a LOJ on 2 fields:
Data.VenGroupNumber --> Claim_Header.Group #
Data.ClaimNumber --> Claim_Header.ClaimNumTxt
I guess what I'm trying to do is mimic and optimize the joins that I currently have between the command and the table but have only 1 'connection' or command... wondering if this can be accomplished in a single command or other method ?
I've read a lot of examples that incuded using a UNION but it sounds like each query needs to have the same number of fields and data types to use this.