Results 1 to 7 of 7
  1. #1
    Join Date
    May 2010
    Posts
    4

    Unanswered: Newbie question about query

    Does this look syntactically correct?

    HTML Code:
    USE Claims;
    GO
    SELECT mch.Claim,
           mch.encounter As MedicalEncounter, 
           mp.procedure As ProductPerformed,
           md.diagnosis As DiagonisisMade 
     
    FROM MedicalClaimsHeader as mch
    
    INNER JOIN MedicalProcedure as mp
    ON mp.ClaimNumber = mch.ClaimNumber
    INNER JOIN MedicalDiagonis as md
    ON mch.ClaimNumber = md.ClaimNumber
    WHERE
    mp.Procedure = 8694 AND md.Diagonis <> 4019 
    ORDER BY mch.Claim ASC;
    GO

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    The word "Procedure" is reserved, so you may need to put that in brackets, but it otherwise looks OK. Is it giving you an error?

  3. #3
    Join Date
    May 2010
    Posts
    4
    No just wanted someone to check it. Newbie just trying to learn the best I can. Thanks for the catch on Procedure.

    One other question, I have another query Im working on and am stuck. I need to find every row where the same procedure was performed multiple times on the same day. Any hints?

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Without more info, we're as stumped as you!
    Provide your DDL, sample data and expected output (perhaps include your attempts too)
    George
    Home | Blog

  5. #5
    Join Date
    May 2010
    Posts
    4
    HTML Code:
    USE Claims;
    GO
    SELECT mch.MemberNumber, mch.ClaimNumber, mcd.ClaimNumber, mcd.Procedure, 
           mcd.ProcedureDate, mcd.LineNumber
    FROM  MedicalClaimsHeader as mch
    INNER JOIN MedicalClaimDetail as mcd
    ON mcd.ClaimNumber = mch.ClaimNumber
    WHERE
    mcd.Procedure = J9375
    ORDER BY 5,1 ASC;
    GO
    Sorry for the late response. Here is my attempt.

    Need every procedure performed multiple times on same day for same member? This right or wrong?

  6. #6
    Join Date
    Dec 2007
    Location
    Richmond, VA
    Posts
    1,328
    Provided Answers: 5
    it is nowhere near correct.
    First, you say for every procedure, yet you equate to a single procedure.
    Then you have no kind of comparison to a date field of a timestamp field, so no way to tell what day the updates are from.
    Try something along the lines of:
    select member
    from table
    where date equals todays date
    group by member
    having count(*) > 1
    Dave

  7. #7
    Join Date
    May 2010
    Posts
    4
    Better?

    Code:
    USE Claims;
    GO
    SELECT mch.MemberNumber, mch.ClaimNumber, mcd.ClaimNumber, mcd.Procedure, 
           mcd.ProcedureDate, mcd.LineNumber
    FROM  MedicalClaimsHeader as mch
    INNER JOIN MedicalClaimDetail as mcd
    ON mcd.ClaimNumber = mch.ClaimNumber
    WHERE
    mcd.ProcedureDate = Count(*) > 1 AND mcd.Procedure = J1234
    GROUP BY mch.MemberNumber
    Having Count(*) > 1
    ;
    GO

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •