NEW Ket Database SQL Combat 1-Find all information for the latest onboarding staff

Source: Internet
Author: User

Title describes all information for finding the latest entry staff
CREATE TABLE ' Employees ' (
' Emp_no ' int (one) is not NULL,
' Birth_date ' date not NULL,
' first_name ' varchar (not NULL),
' last_name ' varchar (+) not NULL,
' Gender ' char (1) Not NULL,
' Hire_date ' date not NULL,
PRIMARY KEY (' emp_no ')); Enter a description:
No
Output Description:
Emp_no birth_date first_name last_name Gender hire_date
10008 1958-02-19 Saniya Kalloufi M 1994-09-15
Test data

INSERT into Employees VALUES (10001, ' 1953-09-02 ', ' Georgi ', ' Facello ', ' M ', ' 1986-06-26 ');
INSERT into Employees VALUES (10002, ' 1964-06-02 ', ' Bezalel ', ' Simmel ', ' F ', ' 1985-11-21 ');
INSERT into Employees VALUES (10003, ' 1959-12-03 ', ' parto ', ' Bamford ', ' M ', ' 1986-08-28 ');
INSERT into Employees VALUES (10004, ' 1954-05-01 ', ' Chirstian ', ' Koblick ', ' M ', ' 1986-12-01 ');
INSERT into Employees VALUES (10005, ' 1955-01-21 ', ' Kyoichi ', ' Maliniak ', ' M ', ' 1989-09-12 ');
INSERT into Employees VALUES (10006, ' 1953-04-20 ', ' Anneke ', ' preusig ', ' F ', ' 1989-06-02 ');
INSERT into Employees VALUES (10007, ' 1957-05-23 ', ' Tzvetan ', ' Zielinski ', ' F ', ' 1989-02-10 ');
INSERT into Employees VALUES (10008, ' 1958-02-19 ', ' Saniya ', ' Kalloufi ', ' M ', ' 1994-09-15 ');
INSERT into Employees VALUES (10009, ' 1952-04-19 ', ' sumant ', ' peac ', ' F ', ' 1985-02-18 ');
INSERT into Employees VALUES (10010, ' 1963-06-01 ', ' Duangkaew ', ' Piveteau ', ' F ', ' 1989-08-24 ');
INSERT into Employees VALUES (10011, ' 1953-11-07 ', ' Mary ', ' Sluis ', ' F ', ' 1990-01-22 ');

Reference answer

SELECT * FROM Employees ORDER BY hire_date Desc LIMIT 1

Analytical

---Sort the results of a query

The Order By field name [DESC/ASC] is ASC ascending by default, and the sort field needs to be a data type that can be compared

Limit is generally used in two ways,

----

SELECT * FROM table limit M,n
where m refers to the beginning of the record index, starting from 0, indicating the first record
n means starting from section m+1 and taking N.

SELECT * FROM table limit n
This means that the first n data is taken from the record, which is equivalent to omitting the m=0

NEW Ket Database SQL Combat 1-Find all information for the latest onboarding staff

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.