# Find out the current salary details for each department (to_date= ' 9999-01-01 ') and its corresponding department number Dept_no

Source: Internet
Author: User

Topic Description Find all Departments current (to_date= ' 9999-01-01 ') leadership current salary details and their corresponding department number Dept_no

```CREATE TABLE ' Dept_manager ' (
' Dept_no ' char (4) NOT NULL,
' emp_no ' int (one) not null,
' from_date ' date not NULL ,
' to_date ' date not NULL,
PRIMARY KEY (' emp_no ', ' dept_no '));
```
```CREATE TABLE ' salaries ' (
' emp_no ' int (one) not null,
' salary ' int (one) not null,
' from_date ' date not NULL,
' to_date ' date not NULL,
PRIMARY KEY (' emp_no ', ' from_date '));```

Enter a description:
`No`
Output Description:
Emp_no Salary from_date to_date Dept_no
10002 72527 2001-08-02 9999-01-01 d001
10004 74057 2001-11-27 9999-01-01 d004
10005 94692 2001-09-09 9999-01-01 d003
10006 43311 2001-08-02 9999-01-01 d002
10010 94409 2001-11-23 9999-01-01 d006
Example 1 input
`No`
Output
`No`
Solution:

This problem needs to be examined carefully, with the following considerations. The table is a two-table association table, but the elements cannot be repeated, and you need to salaries the table's field order, all the fields in the table, and the department number the employee number of the table-emp_no is incremented sequentially, so you need to place the salaries table in the front

```Select S.*,d.dept_no from
salaries as s,dept_manager as D
where s.to_date= "9999-01-01" and
d.to_date= " 9999-01-01 "and
d.emp_no = S.emp_no```
Related Keywords:

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.