Skip to content

Instantly share code, notes, and snippets.

@faizakram
Last active January 18, 2023 05:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save faizakram/f80962b6340469ba802e7c898c76c63d to your computer and use it in GitHub Desktop.
Save faizakram/f80962b6340469ba802e7c898c76c63d to your computer and use it in GitHub Desktop.
SELECT t1.name user_name, dep.name department, t1.created_on
FROM employee t1 JOIN department dep ON t1.department_id =dep.id
WHERE t1.created_on = (SELECT MAX(t2.created_on)
FROM employee t2
WHERE t2.department_id = t1.department_id);
-- If not exists in the child table
SELECT p.id
FROM project p
WHERE NOT EXISTS (
SELECT 1 FROM project_description pd
WHERE pd.project_id= p.id AND pd.project_service_type_id =33
) ORDER BY p.id;
@faizakram
Copy link
Author

Department
image
Employee Table
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment