Canstralian commited on
Commit
23f0303
·
verified ·
1 Parent(s): 22b627f

Update example_queries.py

Browse files
Files changed (1) hide show
  1. example_queries.py +29 -46
example_queries.py CHANGED
@@ -1,49 +1,32 @@
1
- small_query=""" Tables:
2
- CREATE TABLE table_name_11 (date VARCHAR, away_team VARCHAR)
3
-
4
- Question:
5
- On what Date did the Away team essendon play?
6
-
7
- Answer:"""
8
- long_query="""Tables:
9
-
10
  CREATE TABLE employees (
11
- EMPLOYEE_ID decimal(6,0), FIRST_NAME varchar(20),
12
- LAST_NAME varchar(25), EMAIL varchar(25),
13
- PHONE_NUMBER varchar(20), HIRE_DATE date,
14
- JOB_ID varchar(10), SALARY decimal(8,2),
15
- COMMISSION_PCT decimal(2,2), MANAGER_ID decimal(6,0),
16
- DEPARTMENT_ID decimal(4,0)
17
- )
18
- CREATE TABLE jobs (
19
- JOB_ID varchar(10), JOB_TITLE varchar(35),
20
- MIN_SALARY decimal(6,0), MAX_SALARY decimal(6,0)
21
- )
22
- CREATE TABLE locations (
23
- LOCATION_ID decimal(4,0), STREET_ADDRESS varchar(40),
24
- POSTAL_CODE varchar(12), CITY varchar(30),
25
- STATE_PROVINCE varchar(25), COUNTRY_ID varchar(2)
26
- )
27
- CREATE TABLE countries (
28
- COUNTRY_ID varchar(2), COUNTRY_NAME varchar(40),
29
- REGION_ID decimal(10,0)
30
- )
31
- CREATE TABLE job_history (
32
- EMPLOYEE_ID decimal(6,0), START_DATE date,
33
- END_DATE date, JOB_ID varchar(10),
34
- DEPARTMENT_ID decimal(4,0)
35
- )
36
- CREATE TABLE regions (
37
- REGION_ID decimal(5,0), REGION_NAME varchar(25)
38
- )
39
- CREATE TABLE departments (
40
- DEPARTMENT_ID decimal(4,0), DEPARTMENT_NAME varchar(30),
41
- MANAGER_ID decimal(6,0),LOCATION_ID decimal(4,0)
42
- )
43
-
44
- Question:
45
 
46
- For those employees who did not have any job in the past, give me the comparison about the amount of job_id over the job_id , and group by attribute job_id, and list from low to high by the JOB_ID please.
 
 
 
 
 
 
 
 
47
 
48
- Answer:
49
- """
 
 
 
 
 
 
1
+ -- Create the 'employees' table with appropriate data types
 
 
 
 
 
 
 
 
2
  CREATE TABLE employees (
3
+ employee_id INT PRIMARY KEY,
4
+ first_name VARCHAR(20),
5
+ last_name VARCHAR(25),
6
+ email VARCHAR(25),
7
+ phone_number VARCHAR(20),
8
+ hire_date DATE,
9
+ job_id VARCHAR(10),
10
+ salary DECIMAL(8,2),
11
+ commission_pct DECIMAL(2,2),
12
+ manager_id INT,
13
+ department_id INT
14
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
+ -- Create the 'job_history' table with appropriate data types
17
+ CREATE TABLE job_history (
18
+ employee_id INT,
19
+ start_date DATE,
20
+ end_date DATE,
21
+ job_id VARCHAR(10),
22
+ department_id INT,
23
+ PRIMARY KEY (employee_id, start_date)
24
+ );
25
 
26
+ -- Query to find employees without any job history and count occurrences of each job_id
27
+ SELECT e.job_id, COUNT(e.job_id) AS job_count
28
+ FROM employees e
29
+ LEFT JOIN job_history jh ON e.employee_id = jh.employee_id
30
+ WHERE jh.job_id IS NULL
31
+ GROUP BY e.job_id
32
+ ORDER BY e.job_id;