Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Simple Query Help Please

Engaged ,
May 01, 2008 May 01, 2008
I have two related tables. tblVisits, and tblProcedure. Each Visit has one or more procedures, linked on VisitIDNo.

What is the syntax to return ALL the visits, and only the FIRST procedure (CPT4)?

<cfquery name="GetAll" datasource="PaceAce">
SELECT tblVisits.VisitIDNo, tblProcedure.VisitIDNo, tblProcedure.CPT4
FROM tblVisits
JOIN tblProcedure ON tblVisits.VisitIDNo = tblProcedure.VisitIDNo
</cfquery>
320
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 01, 2008 May 01, 2008
I solved it by using DISTINCT.

Not sure if that is the textbook way, though.

<cfquery name="GetAll" datasource="PaceAce">
SELECT DISTINCT tblVisits.VisitIDNo, tblProcedure.VisitIDNo, tblProcedure.CPT4
FROM tblVisits
JOIN tblProcedure ON tblVisits.VisitIDNo = tblProcedure.VisitIDNo
</cfquery>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 01, 2008 May 01, 2008
I'm wondering why your business rules don't compel you to identify a primary procedure.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 02, 2008 May 02, 2008
LATEST
Long story, but we are not a typical health organization. I agree that just about every other health care environment would dictate a primary procedure. I have been fighting that battle for years.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources