SQL server interview questions, SQL SERVER interview questions

Source: Internet
Author: User

SQL server interview questions, SQL SERVER interview questions

I went to the interview today and got caught by a small database problem. I am ashamed and brave.



SQL interview questions

1. I can't help but want to say this, because the field type in the first question is [date type], and there are different methods to operate on date type data in various databases. There is no common method, therefore, there is no common SQL beyond the database.

2. select ID, NAME, ADDRESS, PHONE, LOGDATE from T
Where ID in (select ID from T group by NAME having count (*)> 1)
Order by NAME;

3. delete from T where ID not in
(Select min (id) from T group by name );

4. update T
Set T. ADDRESS = (select E. ADDRESS from E where E. NAME = T. NAME ),
T. PHONE = (select E. PHONE from E where E. NAME = T. NAME );

5. This different database also has different processing methods and cannot be separated from the database.
For example, SQL Server or access can use top
Oracle can use rownum and so on

---
The above is helpful to you.

One SQL Server interview question. The employee table (employees) fields include the employee ID, salary, hireDate, and deptId (foreign key) Department table.

Select t1.departmentname, t1.leader, avg (t2.salary) as average salary
From department t1,
Employees t2
Where t1.id = t2.deptid
Group by t1.departmentname, t1.leader

Related Article

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.