Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The head of hospital auditing wants to know which patients were charged the most for a treatment. The result table should list three columns from

The head of hospital auditing wants to know which patients were charged the most for a treatment. The result table should list three columns from the treatment table appropriately labeled: pat_id, actual_charge, and service _id .Only list rows where the patient was charged the most for a treatment. This may result in some rows where patients were charged identical amounts to other patients. Sort the rows by service_id. Use a correlated subquery. Format the output appropriately.

I executed :

select pat_id, actual_charge from treatment where actual_charge > (select avg(service_charge - actual_charge) from service where service_cat_id = 'SUR');

and got this error message:

Msg 8124, Level 16, State 1, Line 12 Multiple columns are specified in an aggregated expression containing an outer reference. If an expression being aggregated contains an outer reference, then that outer reference must be the only column referenced in the expression.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions

Question

differentiate the function ( x + 1 ) / ( x ^ 3 + x - 6 )

Answered: 1 week ago