Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sql-queries-3/order-number-strings/ordering-mssql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT * FROM Exam ORDER BY CAST(attendance_points AS INT);

SELECT * FROM Exam ORDER BY CONVERT(INT, attendance_points);

SELECT * FROM Exam ORDER BY attendance_points+0;
5 changes: 5 additions & 0 deletions sql-queries-3/order-number-strings/ordering-mysql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT * FROM Exam ORDER BY attendance_points+0;

SELECT * FROM Exam ORDER BY CONVERT(attendance_points, SIGNED);

SELECT * FROM Exam ORDER BY CAST(attendance_points AS SIGNED);
4 changes: 4 additions & 0 deletions sql-queries-3/order-number-strings/ordering-pg.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SELECT * FROM Exam ORDER BY CAST(attendance_points AS INT);

SELECT * FROM Exam ORDER BY attendance_points::INT;

8 changes: 8 additions & 0 deletions sql-queries-3/order-number-strings/setup.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ALTER TABLE Exam ADD attendance_points VARCHAR(10);
DELETE FROM Exam WHERE id > 4;
UPDATE Exam SET attendance_points = '100' WHERE id=1;
UPDATE Exam SET attendance_points = '-25' WHERE id=2;
UPDATE Exam SET attendance_points = '45' WHERE id=3;
UPDATE Exam SET attendance_points = '-99' WHERE id=4;

SELECT id, attendance_points FROM Exam;