Skip to content

Commit 277080a

Browse files
Merge pull request #347 from yadavan88/alias-queries
Alias AS query
2 parents fb12279 + fda6423 commit 277080a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
SELECT name, gpa AS grade_point_average
2+
FROM Student;
3+
4+
SELECT name, graduation_date - enrollment_date AS study_duration_in_days
5+
FROM Student;
6+
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+
11+
SELECT s.name,e.course_id,e.grade
12+
FROM Student AS s
13+
JOIN Exam AS e ON s.id = e.student_id
14+
WHERE e.grade IS NOT NULL;
15+
16+
SELECT s.name,s.gpa
17+
FROM Student AS s, (SELECT AVG(gpa) AS overall_avg_gpa FROM Student) AS avg_gpa_subquery
18+
WHERE s.gpa > avg_gpa_subquery.overall_avg_gpa;

0 commit comments

Comments
 (0)