Skip to content

Commit fda6423

Browse files
authored
added example for sql server
1 parent ec40679 commit fda6423

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sql-queries-11/as-alias/as-alias.sql

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ FROM Student;
44
SELECT name, graduation_date - enrollment_date AS study_duration_in_days
55
FROM Student;
66

7+
-- ONLY in SQL Server since - operator not supported for date
8+
SELECT name, DATEDIFF(DAY, enrollment_date, graduation_date) AS study_duration_in_days
9+
FROM Student;
10+
711
SELECT s.name,e.course_id,e.grade
812
FROM Student AS s
913
JOIN Exam AS e ON s.id = e.student_id
1014
WHERE e.grade IS NOT NULL;
1115

1216
SELECT s.name,s.gpa
1317
FROM Student AS s, (SELECT AVG(gpa) AS overall_avg_gpa FROM Student) AS avg_gpa_subquery
14-
WHERE s.gpa > avg_gpa_subquery.overall_avg_gpa;
18+
WHERE s.gpa > avg_gpa_subquery.overall_avg_gpa;

0 commit comments

Comments
 (0)