Oracle, MySQL, SQL Server three database usage differences

1. Use connectors to connect fields
Connect the student name and gender in the student information table (t_student) to query student information
Oracle:
SELECT stuId, stuName||sex FROM t_student;
MySQL:
SELECT stuId, CONCAT(stuName,sex) FROM t_student;
SQL Server:
SELECT stuId, stuName+sex FROM t_student;

2. Use ROLLUP keyword
statistics to group the departments and teacher titles in the teacher information table, and make statistics on the teachers' salaries after grouping
Oracle:
SELECT dept,profession,SUM (salary) FROM t_teacher GROUP BY ROLLUP(dept,profession);
MySQL:
SELECT dept,profession,SUM(salary) FROM t_teacher GROUP BY dept,profession WHIT ROLLUP;
SQL Server:
SELECT dept,profession,SUM(salary) FROM t_teacher GROUP BY dept,profession WHIT ROLLUP;

3. Limit the number of rows in the result set
Query the teacher information in the teacher information table, and only display the 4th to 6th records sorted according to the teacher number in ascending order
Oracle:
SELECT teaId,teaName,dept,profession FROM (SELECT ROWNUM AS rn,teaId,teaName,dept,profession FROM t_teacher WHERE ROWNUM<=6) WHERE rn>=4;
MySQL:
SELECT teaId,teaName,dept,profession FROM t_teacher ORDER BY teaId LIMIT 3,3;
SQL Server:
SELECT teaId,teaName,dept,profession FROM (SELECT TOP 6 teaId AS r,teaName,dept,profession FROM t_teacher) WHERE r>=4;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326119471&siteId=291194637