SQL_Generation / example_queries.py
Canstralian's picture
Update example_queries.py
23f0303 verified
raw
history blame
888 Bytes
-- Create the 'employees' table with appropriate data types
CREATE TABLE employees (
employee_id INT PRIMARY KEY,
first_name VARCHAR(20),
last_name VARCHAR(25),
email VARCHAR(25),
phone_number VARCHAR(20),
hire_date DATE,
job_id VARCHAR(10),
salary DECIMAL(8,2),
commission_pct DECIMAL(2,2),
manager_id INT,
department_id INT
);
-- Create the 'job_history' table with appropriate data types
CREATE TABLE job_history (
employee_id INT,
start_date DATE,
end_date DATE,
job_id VARCHAR(10),
department_id INT,
PRIMARY KEY (employee_id, start_date)
);
-- Query to find employees without any job history and count occurrences of each job_id
SELECT e.job_id, COUNT(e.job_id) AS job_count
FROM employees e
LEFT JOIN job_history jh ON e.employee_id = jh.employee_id
WHERE jh.job_id IS NULL
GROUP BY e.job_id
ORDER BY e.job_id;