Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a query to display the minimum, maximum, and average, and total number of lab tests resulted for patients born in each year between 1990

Write a query to display the minimum, maximum, and average, and total number of lab tests resulted for patients born in each year between 1990 and 2000 and living in California. Display patient year of birth, minimum number of lab tests, maximum number of lab tests, average number of lab tests number of lab tests and total number of lab tests resulted for patients having each birth year. Be sure each field is displayed with a meaningful, user-friendly name. Query needs to be edited to reflect answer.


 SELECT DISTINCT(LabResultID),
       `p`.`State` AS `State`,
       `p`.`Gender` AS `Gender`,
       `p`.`YearOfBirth` AS `YearOfBirth`,
       `p`.`PatientID` AS `patientId`,
       COUNT(`r`.`LabResultID`) AS `NumLabs`,
       Min(LabResultID) AS MinLabResults
       FROM
       (`patients` `p`
       JOIN `labresult` `r` ON (`p`.`PatientID` = `r`.`PatientID`))
   GROUP BY `p`.`State` , `p`.`Gender` , `p`.`YearOfBirth` , `p`.`PatientID`

Step by Step Solution

3.36 Rating (149 Votes )

There are 3 Steps involved in it

Step: 1

Sql SELECT pYearOfBirth AS BirthYear MINrLabResultID AS MinLabResul... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Contemporary Management

Authors: Gareth Jones, Jennifer George

9th Edition

0077718372, 978-0077718374

More Books

Students also viewed these Databases questions

Question

Name five cash inflows that would qualify as a Financing Activity.

Answered: 1 week ago

Question

please answer completely and correctly thanks!

Answered: 1 week ago