Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 955125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:19:49+00:00 2026-05-16T00:19:49+00:00

I’m trying to write a report to hit a very large database, which makes

  • 0

I’m trying to write a report to hit a very large database, which makes the use of subreports… unpleasant to say the least. How can I avoid them in this situation:

I’m starting from a table of patient visits. Each visit can have multiple vital readings (Say in a ‘Vitals’ table that is many-to-one with the visit table) of which I want the min and max of each type. So to accomplish this, I group by the patient visits and then use formulas to calculate the min/maxes and display them in the group footer. So far so good. However, there is another table, Orders, that contains all the orders for that visit as well, of which I also want to select some min/max values to display for the encounter.

To skirt using a subreport, I added some more formulas to the suppressed details that also find the min/max of these order values and display in the group footer. The problem is that Crystal only returns patient visits that have orders (despite being outer-joined), and what I need is a list of ALL visits that may or may not have any orders whatsoever. To complicate matters further, there is yet another Orders table I need to do this with as well (one for medication and one for procedures). Any ideas?

(visitID, patName, visitDate)
------------------------------------------------------------------
1, Patient A, July-24-2009
2, Patient B, July-25-2009

(visitID, line, medName, dosage)
------------------------------------------------------------------
1, 1, Aspirin, 200mg
1, 2, Aspirin, 500mg
2, 1, Codeine, 100mg
2, 2, Codeine, 200mg
2, 3, ValerianCap, 700mg

(visitID, line, procName, procType, cost)
------------------------------------------------------------------
1, 1, Xray-wrist, xray, $500
1, 2, Xray-elbow, xray, $300

+-----------------------------------------------
| Patient A
|   Med Orders:
|     Max Aspirin Dosage: 500mg
|
|     Proc. Orders:
|     Max cost Xray: $500
|
+-----------------------------------------------
| Patient B
|   Med Orders:
|   ...
+-----------------------------------------------
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T00:19:50+00:00Added an answer on May 16, 2026 at 12:19 am

    You need to flatten your data set I would suggest starting with the query

    Something like this. Note basically you are using union to query each of the Joins to the Detail tables separately. When Done you can group by record type and make multiple sections for the Record Type group (4 sections) Each section will have a suppress condition (Example Vitals section will suppress when RecordType <> Vitals.) Now basically you have created groups instead of subreports.

    SELECT
      'Vitals' As RecordType,
      Vitals.*,
      --Fields For Orders,
      --Fields For Medications,
      --Fields For Procedures  
    FROM Visits 
    LEFT JOIN Vitals ON Vitals.VisitId = Visits.VisitId 
    UNION ALL
    SELECT
      'Orders' As RecordType,
      --Fields for Vitals,
      Orders.*,
      --Fields For Medications,
      --Fields For Procedures  
    FROM Visits 
    LEFT JOIN Orders ON Orders.VisitId = Visits.VisitId
    UNION ALL
    SELECT
      'Medications' As RecordType,
      --Fields for Vitals,
      --Fields For Orders,
      Medications.*,
      --Fields For Procedures  
    FROM Visits 
    LEFT JOIN Medications ON Medications.VisitId = Visits.VisitId
    UNION ALL
    SELECT
      'Procedures' As RecordType,
      --Fields For Vitals,
      --Fields For Orders,
      --Fields For Medications,
      Procedures.*  
    FROM Visits 
    LEFT JOIN Procedures ON Procedures.VisitId = Visits.VisitId
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to select an H1 element which is the second-child in its group
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported
I would like to run a str_replace or preg_replace which looks for certain words

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.