0

Plzz tell how can we use nax(sum()) function in sql

It shows error by this way what is the right way?

21st Feb 2020, 10:00 PM
Amrit Anand
Amrit Anand - avatar
5 Antworten
+ 1
Can you show us your code?
21st Feb 2020, 10:15 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 1
max and sum both will return a single value. So it makes no sense to put sum inside max. What are you actually trying to do?
22nd Feb 2020, 3:27 AM
Avinesh
Avinesh - avatar
+ 1
Yes I can see but what is the result that you want out of that query?
22nd Feb 2020, 5:49 AM
Avinesh
Avinesh - avatar
0
create table patient( patientid int, patientname varchar(20), city varchar(20) ); insert into patient values(101,'kevin','New York'); insert into patient values(102,'Mike','Boston'); insert into patient values(103,'Maria','Chicago'); insert into patient values(104,'Jenny','New York'); insert into patient values(105,'Jack','Chicago'); create table consultation( consultationid int, patientid int, fees int ); insert into consultation values(1,101,200); insert into consultation values(2,102,700); insert into consultation values(3,103,600); insert into consultation values(4,101,500); insert into consultation values(5,105,500); insert into consultation values(6,104,500); select p.patientid,p.patientname,p.city from patient p inner join consultation c on p.patientid=c.patientid group by p.patientid,p.patientname,p.city having sum(fees)> select max(sum(fees)) from patient p1 inner join consultation c1 on p1.patientid=c1.patientid where patientname like '%e%' group by c1.patientid;
21st Feb 2020, 10:24 PM
Amrit Anand
Amrit Anand - avatar
- 1
You can see the code
22nd Feb 2020, 5:47 AM
Amrit Anand
Amrit Anand - avatar