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

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -