Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

table PATIENT created. table BILLING created. table DOCTOR created. PT_ID PT_LNA

ID: 3554875 • Letter: T

Question

table PATIENT created.

table BILLING created.

table DOCTOR created.

PT_ID      PT_LNAME             PT_FNAME             PTDOB     DOC_ID     NEXTAPPTD LASTAPPTD

---------- -------------------- -------------------- --------- ---------- --------- ---------

168        James                Paul                 14-MAR-97 432        01-JUL-03 01-JUN-03

331        Anderson             Brian                31-MAR-48 235        01-JUL-03 01-JUN-03

313        James                Scott                26-MAR-33 235        20-JUL-03 20-JUN-03

816        Smith                Jason                12-DEC-99 509        15-NOV-03 15-MAY-03

314        Porter               Susan                14-NOV-67 235        01-OCT-03 01-MAR-03

315        Saillez              Debbie               09-SEP-55 235        01-JUL-03 01-JUN-03

719        Rogers               Anthony              01-JAN-42 504        01-NOV-03 01-JAN-03

264        Walters              Stephanie            26-JAN-45 504        12-DEC-03 12-DEC-02

267        Westra               Lynn                 12-JUL-57 235        02-FEB-04 02-FEB-03

103        Poole                Jennifer             13-MAY-02 389        01-DEC-03 01-JUN-03

108        Baily                Ryan                 25-DEC-77 235        06-JUN-05 06-JUN-03

943        Crow                 Lewis                10-NOV-49 235        01-JUL-05 01-MAR-02

847        Cochran              John                 28-MAR-48 356        02-DEC-05 01-JAN-02

163        Roach                Becky                08-SEP-75 235        01-DEC-05 01-JAN-02

504        Jackson              John                 08-NOV-43 235        21-JUL-03 10-NOV-02

809        Kowalczyk            Paul                 12-NOV-51 558        29-JUL-03 19-JUN-03

703        Davis                Linda                17-JUL-02 509        21-JUL-03 22-MAY-03

307        Jones                J.C.                 17-JUL-02 509        21-JUL-03 22-MAY-03

439        Wright               Chasity              23-APR-73 235                            

696        Vanderchuck          Keith                08-AUG-68 504                  15-JUN-03

966        Mcginnis             Allen                03-MAY-59 504                  15-JUN-03

669        Sakic                Joe                  16-SEP-76 504                  15-JUN-03

22 rows selected

PT_ID                   BALANCE DUEDATE   PHONE      ADDR                           CITY                 ST ZIP   PT_INS            

-------------------- ---------- --------- ---------- ------------------------------ -------------------- -- ----- --------------------

168                       15650 21-AUG-03 833-9569   128 W. APPLE #4                Jonesboro            IL 62952 SIH                 

331                        300 09-SEP-03 833-5587   3434 Mulberry St.              Anna                 IL 62906 BCBS                

313                           0 01-JAN-04 893-9987   334 Tailgate Ln                COBDEN               IL 62920 Military            

816                           0 01-JAN-04 833-6654   8814 W. Apple                  JONESBORO            IL 62952 SIH                 

314                         100 31-MAR-03 457-6658   445 Oak St.                    Carbondale           IL 62901 BCBS                 

264                       35000 11-JAN-03 942-8065   8898 Bighill Driver            HERRIN               IL 62948 MediSupplA          

103                        4500 01-JUL-03 833-5547   298 Murphy School Rd           Anna                 IL 62906 HealthCare          

108                           0 01-JAN-05 833-5542   334 Pansie Hill Rd.            JONESBORO            IL 62952 HealthCare          

943                           0 01-JAN-07 529-9963   456 E. Grand #14               Carbondale           IL 62901 Military            

847                       98000 31-JAN-02 549-8854   6543 W. Parkview Ln.           Carbondale           IL 62901 BCBS                

504                           0 01-JAN-03 549-6139   6657 N. Allen                 Carbondale           IL 62901 QualityCare         

809                         450 19-JUL-03 687-8852   3345 Hwy 127 N.                Murphysboro          IL 62966 QualityCare         

703                         225 31-AUG-03 529-8332   909 N. Brown St.               Carbondale           IL 62901 HealthCare          

696                       79850 15-JUL-03 549-7231   5546 W. James                  Carbondale           IL 62901 BCBS                

966                       98700 15-JUL-03 833-5375   9009 Taylor Ave.               Anna                 IL 62906 BCBS                

267                           0 01-JAN-05 942-3321   6755 US Route 148              HERRIN               IL 62948 QualityCare         

307                         450 31-AUG-03 457-6967   234 N. Allen                   Carbondale           IL 62901 HealthCare          

719                           0 01-JAN-04 549-7848   867 Henderson St.              Carbondale           IL 62901 HealthCare          

439                         500 31-AUG-03 833-5541   4456 N. Springer               Anna                 IL 62906 QualityCare         

315                        1500 14-SEP-03 833-6272   404 Williford Rd.              JONESBORO            IL 62952 HealthCare          

163                           0 01-JAN-04 833-2133   129 Fountain St.               Anna                 IL 62906 HealthCare          

669                      128450 15-JUL-03 833-6654   353 Tin Bender Rd.             Jonesboro            IL 62952 BCBS                 

22 rows selected

DOC_ID     DOC_NAME             DATEHIRED SALPERMON AREA                 SUPERVISOR_ID CHGPERAPPT ANNUAL_BONUS

---------- -------------------- --------- ---------- -------------------- ------------- ---------- ------------

432        Harrison             05-DEC-94      12000 Pediatrics                     100         75         4500

509        Vester               09-JAN-02       8100 Pediatrics                     432         40             

389        Lewis                21-JAN-96      10000 Pediatrics                     432         40         2250

504        Cotner               16-JUN-98      11500 Neurology                      289         85         7500

235        Smith                22-JUN-98       4550 Family Practice                100         25         2250

356        James                01-AUG-98       7950 Neurology                      289         80         6500

558        James                02-MAY-95       9800 Orthopedics                    876         85         7700

876        Robertson            02-MAR-95      10500 Orthopedics                    100         90         8900

889        Thompson             18-MAR-97       6500 Rehab                          100         65         3200

239        Pronger              18-DEC-99       3500 Rehab                          889         40             

289        Borque               30-JUN-89      16500 Neurology                      100         95         6500

100        Stevenson            30-JUN-79      23500 Director                                                  

12 rows selected

Display the number of doctors that currently have patients. Note: Check for accuracy.

Show the total annual bonus earned by doctors hired in the year entered by the user. Note: Try 1998.

Display the lowest and highest charge per appointment. Note: Use MAX and MIN functions.

Display the number of patients currently assigned to each doctor.

For each area of specialization, display the number of patients from each town represented.

For all areas with at least two doctors, display the average charge per appointment, rounded to the nearest dollar and appropriately formatted.

For all doctors except numbers 432 and 509, display the average balance owned by their patients in ascending order. Ignore groups with a total of less than $100 owned.

Display the names of doctors in Dr. Harrison's area. Note: The piece of information that needs to be determined first is Dr. Harrison's area).

Display the names and salaries of doctors who earn more than the average salary.

Display the names of doctors who are also supervisors.

Display the names and monthly salaries of doctors who earn more than all of the doctors in pediatrics. Note: Use the ALL operator.

Display the names and charges per appointment for doctors that charge more per appointment than any one of the doctors in neurology. Note: Use the ANY operator.

Display the names of doctors that have the same area and charge per appointment as Dr. Lewis does. Note: Dr. Lewis should not be in your output.

Show the IDs of the patients who live in the same town as patient number 168. Note: Check for accuracy.

Susan Porter has canceled her next appointment. In order to try to fill her spot, display the names and next appointment dates of patients who have appointments with her doctor on a later date.

Explanation / Answer

The Queries are as follows:

DOING SOME QUERIES HERE. Need the actual databse to do all of them.

1. Select DOC_NAME from `DOCTOR` WHERE DOC_ID in (SELECT DOC_ID FROM `PATIENT` WHERE PT_ID >0) (With repition of doctor names).

2. Select ANNUAL BONUS from `DOCTOR` WHERE (select RIGHT(DATEHIRED FROM `DOCTOR` WHERE 1,2) =98)

3. MAX = SELECT MAX(ANNUAL_BONUS) FROM `DOCTOR`;

MIN = SELECT MIN(ANNUAL_BONUS) FROM `DOCTOR`;