+ 1
Could you help me with this query?
given a teacher table to determine how many teacher have been hired each year the output would be the year and how many hired in that year
4 ответов
+ 2
SELECT teacher_name, id FROM teachers WHERE year_hired = given_year
something like that?
+ 2
Use <= or a Function
+ 1
But I also want of other years in the same query ??
+ 1
1.- If you have...create table
Create table teacher
(id int not null autoincrement PRIMARY KEY,
name varchar(250) not null,
hire_date date not null)
2.- You can do this:
select
datepart(YEAR,hire_date) as Year,
count(id) as hired_teachers
from teacher
group by datepart(YEAR,hire_date)
3.- the result sum all registres agrouped by year of hire_date