0

Need help in sql query problem

Anyone wanna dusscuss

21st Feb 2020, 10:53 PM
Amrit Anand
Amrit Anand - avatar
5 ответов
+ 1
I managed to make it work by splitting the functions. Change this line: select max(sum(fees))...; to this: select max(s) from (select sum(fees) s from ... group by c1.patientid) s;
21st Feb 2020, 11:34 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
0
Maybe i could help.
21st Feb 2020, 11:02 PM
Ignas Juodžiukynas
Ignas Juodžiukynas - 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, 11:08 PM
Amrit Anand
Amrit Anand - avatar
0
Run this code and tell what should be the answer
21st Feb 2020, 11:09 PM
Amrit Anand
Amrit Anand - avatar
0
Ans
8th Feb 2022, 11:23 AM
For Fun