0
Need help in sql query problem
Anyone wanna dusscuss
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;
0
Maybe i could help.
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;
0
Run this code and tell what should be the answer
0
Ans