1
votes

I'm not sure where the error is,

(Error at Line 2)

(Help)

select last_name, first_name 
from employee group by Employee_ID in 
select Employee_ID from service group by Property_ID having count(*)>2; 

employee table create table EMPLOYEE( Employee_ID int primary key, Last_name char(30), First_Name char(30), CellPhone char(20), ExperienceLevel char(30), CONSTRAINT EX_EMPLOYEE_EXPERIENCELEVEL CHECK (ExperienceLevel IN('Master', 'Junior', 'Senior')) );

service Table create table SERVICE ( Property_ID int, Employee_ID int, Service_Date date, Hours_worked int, primary key(Property_ID, Employee_ID), foreign key(Property_ID) references PROPERTY(Property_ID), foreign key(Employee_ID) references EMPLOYEE(Employee_ID) );

property table create table PROPERTY( Property_ID int primary key, Owner_ID int, Owner_Name char(30), Owner_email char(30), Owner_type char(30), CONSTRAINT EX_PROPERTY_OWNERTYPE CHECK (Owner_type IN('Individual', 'Corporate', 'Partnership')) );

1
Edit your question and include the Text of the query and the error message. (not links to images of text) - MatBailie
The word in after the group by clause on the second line is syntactically invalid in that place. The query should have ended there (or at least the parser, which doesn't know what you really wanted to do, thinks the query should have ended there). But that's only one small mistake in your query; in fact the entire query doesn't make any sense - you will probably run into five or six more mistakes after you fix that one. If you want help with the query (rather than the much more modest task of explaining this particular and rather uninteresting error), tell us what you really need - mathguy

1 Answers

0
votes

Your query is not very clear. The in clause before the subquery is not a valid clause at that position. If you want to select the employes whose id are in the subquery, so you have to do something like this:

select last_name, first_name
from   employee
WHERE  Employee_ID in
(select Employee_ID from service
group by Property_ID having count(*)>2);