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