简体   繁体   English

mysql - 选择特定年份后出生的人

[英]mysql - selecting people born after a certain year

I have a table of employees which includes a column birth_day as well as PRIMARY KEY of emp_ID (employee ID).我有一个员工表,其中包括一列birth_day 以及 emp_ID(员工 ID)的 PRIMARY KEY。 There is also another table called Works_With with the employee emp_ID and total_sales by employee还有另一个名为 Works_With 的表,其中包含员工 emp_ID 和员工的 total_sales

What I want to do is to select the top 5 performing employees born after certain year, which is 1970.我想要做的是选择某一年,也就是 1970 年之后出生的表现最好的 5 名员工。

How would I proceed..我将如何进行..

I am thinking it was this but didn't work我想是这个,但没有用

SELECT total_sales
FROM works_with
WHERE employee.birth_day => '1970/MM/DD' LIMIT 5 DESC;

Any suggestions?有什么建议?

If your birth_day column holds a datetime, this should work:如果您的birth_day列包含日期时间,这应该有效:

SELECT employee.emp_ID, total_sales
FROM works_with
INNER JOIN employee
ON works_with.emp_ID = employee.emp_id
       AND year(employee.birth_day) >= 1970 
ORDER BY total_sales DESC
LIMIT 5;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM