sql - Getting max count from a view -
i created view allows me view number of appointments doctor has.
view code:
create view docapps select d.doctorid, d.surname ||','|| d.given "doctor", count(*) "appointments" doctor d, appointment d.doctorid=appointment.doctorid group d.doctorid, d.surname, d.given; and need show doctor appointments, , have used code, has worked in previous queries:
select doctor, appointments docapps appointments in (select max(appointments) docapps); but returning "appointments" : invalid identifier, when have specified that?
using double quotes (") make object names such tables , columns case-sensitive, leads problem. drop them view declaration , should fine:
create view docapps select d.doctorid, d.surname ||','|| d.given doctor, count(*) appointments doctor d, appointment d.doctorid=appointment.doctorid group d.doctorid, d.surname, d.given;
Comments
Post a Comment