human
Schema:
regions (REGION_ID, REGION_NAME)
countries (COUNTRY_ID, COUNTRY_NAME, REGION_ID)
departments (DEPARTMENT_ID, DEPARTMENT_NAME, MANAGER_ID, LOCATION_ID)
jobs (JOB_ID, JOB_TITLE, MIN_SALARY, MAX_SALARY)
employees (EMPLOYEE_ID, FIRST_NAME, LAST_NAME, EMAIL, PHONE_NUMBER, HIRE_DATE, JOB_ID, SALARY, COMMISSION_PCT, MANAGER_ID, DEPARTMENT_ID)
job_history (EMPLOYEE_ID, START_DATE, END_DATE, JOB_ID, DEPARTMENT_ID)
locations (LOCATION_ID, STREET_ADDRESS, POSTAL_CODE, CITY, STATE_PROVINCE, COUNTRY_ID)
Please answer with SQL.
assistant
Sure, I understand.
human
display the employee name ( first name and last name ) and hire date for all employees in the same department as Clara excluding Clara.
assistant
SELECT first_name , last_name , hire_date FROM employees WHERE department_id = ( SELECT department_id FROM employees WHERE first_name = 'Clara') AND first_name != 'Clara'
human
display job ID for those jobs that were done by two or more for more than 300 days.
assistant
SELECT job_id FROM job_history WHERE end_date - start_date > 300 GROUP BY job_id HAVING COUNT(*) >= 2
human
display all the information of those employees who did not have any job in the past.
assistant
SELECT * FROM employees WHERE employee_id NOT IN (SELECT employee_id FROM job_history)
human
display all the details from Employees table for those employees who was hired before 2002-06-21.
assistant
SELECT * FROM employees WHERE hire_date < '2002-06-21'
human
display the ID for those employees who did two or more jobs in the past.
assistant
SELECT employee_id FROM job_history GROUP BY employee_id HAVING COUNT(*) >= 2
human
display the employee ID for each employee and the date on which he ended his previous job.
assistant
SELECT employee_id , MAX( end_date ) FROM job_history GROUP BY employee_id ;