-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Databases week1/parisa #149
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
USE hyf_lesson1 | ||
|
||
SELECT COUNT(*) AS total_tasks FROM task; | ||
|
||
SELECT COUNT(*) AS invalid_due_dates | ||
FROM task | ||
WHERE due_date IS NULL | ||
|
||
SELECT * | ||
FROM task | ||
WHERE status_id = (SELECT id FROM status WHERE name = 'Done'); | ||
|
||
SELECT * | ||
FROM task | ||
WHERE status_id != (SELECT id FROM status WHERE name = 'Done'); | ||
Comment on lines
+9
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice work on using a subquery! |
||
|
||
SELECT * | ||
FROM task | ||
ORDER BY created DESC; | ||
|
||
SELECT * | ||
FROM task | ||
ORDER BY created DESC | ||
LIMIT 1; | ||
|
||
SELECT title, due_date | ||
FROM task | ||
WHERE title LIKE '%database%' | ||
OR description LIKE '%database%'; | ||
|
||
SELECT task.title, status.name AS status | ||
FROM task | ||
JOIN status ON task.status_id = status.id; | ||
|
||
SELECT status.name, COUNT(task.id) AS task_count | ||
FROM status | ||
LEFT JOIN task ON status.id = task.status_id | ||
GROUP BY status.name; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Amazing! You had the attention to detail to use |
||
|
||
SELECT status.name, COUNT(task.id) AS task_count | ||
FROM status | ||
LEFT JOIN task ON status.id = task.status_id | ||
GROUP BY status.name | ||
ORDER BY task_count DESC; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same applies here, use a |
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job on using an alias with the
AS
keryword. 😉There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot, I appreciate your time and suggestions.