question_slug
stringlengths 3
77
| title
stringlengths 1
183
| slug
stringlengths 12
45
| summary
stringlengths 1
160
⌀ | author
stringlengths 2
30
| certification
stringclasses 2
values | created_at
stringdate 2013-10-25 17:32:12
2025-04-12 09:38:24
| updated_at
stringdate 2013-10-25 17:32:12
2025-04-12 09:38:24
| hit_count
int64 0
10.6M
| has_video
bool 2
classes | content
stringlengths 4
576k
| upvotes
int64 0
11.5k
| downvotes
int64 0
358
| tags
stringlengths 2
193
| comments
int64 0
2.56k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
employees-with-missing-information | MySQL || UNION || Easy to understand | mysql-union-easy-to-understand-by-im_obi-53yj | \n# Code\n\n# Write your MySQL query statement below\nselect e.employee_id from employees e left join salaries s on e.employee_id=s.employee_id where s.salary | im_obid | NORMAL | 2023-01-07T07:53:31.274145+00:00 | 2023-01-07T07:53:31.274194+00:00 | 14,579 | false | \n# Code\n```\n# Write your MySQL query statement below\nselect e.employee_id from employees e left join salaries s on e.employee_id=s.employee_id where s.salary is null\nunion \nselect s.employee_id from salaries s left join employees e on e.employee_id=s.employee_id where e.name is null\norder by employee_id;\n\n```\n\n```please upvote, if you find it useful``` | 57 | 0 | ['MySQL'] | 1 |
employees-with-missing-information | MySQL nice and crisp solution | mysql-nice-and-crisp-solution-by-cepheid-qwv8 | \nSELECT employee_id \nFROM employees\nWHERE employee_id NOT IN (SELECT employee_id FROM salaries)\nUNION\nSELECT employee_id \nFROM salaries\nWHERE employee_id | cepheid | NORMAL | 2022-04-12T13:22:13.748403+00:00 | 2022-04-12T13:22:13.748454+00:00 | 5,075 | false | ```\nSELECT employee_id \nFROM employees\nWHERE employee_id NOT IN (SELECT employee_id FROM salaries)\nUNION\nSELECT employee_id \nFROM salaries\nWHERE employee_id NOT IN (SELECT employee_id FROM employees)\nORDER BY employee_id;\n```\nUpvote if you like. | 44 | 0 | [] | 5 |
employees-with-missing-information | MYSQL: Implementing FULL JOIN by Using UNION for Beginners like me. | mysql-implementing-full-join-by-using-un-8ujj | MySQL does not support FULL JOIN, so you have to combine JOIN, UNION and LEFT JOIN to get an equivalent. Here is an another way:\n\n\nSELECT sub.employee_id\nFR | gokhankesler | NORMAL | 2021-08-17T10:50:51.395615+00:00 | 2021-08-17T10:50:51.395664+00:00 | 7,974 | false | MySQL does not support FULL JOIN, so you have to combine JOIN, UNION and LEFT JOIN to get an equivalent. Here is an another way:\n\n```\nSELECT sub.employee_id\nFROM (\n\tSELECT e.employee_id, name, salary\n\tFROM employees AS e\n\tLEFT JOIN salaries AS s\n\tON e.employee_id = s.employee_id\n\t\n\tUNION\n\t\n\tSELECT s.employee_id, name, salary\n\tFROM employees AS e\n\tRIGHT JOIN salaries AS s\n\tON e.employee_id = s.employee_id) AS sub\nWHERE sub.name IS NULL OR sub.salary IS NULL\nORDER BY sub.employee_id\n```\n\nContributions are appreciated...\n\n | 42 | 0 | ['MySQL'] | 4 |
employees-with-missing-information | ✅✅ MYSQL || Union || Two approaches || Left Join || Sub-query | mysql-union-two-approaches-left-join-sub-cuet | Please Upvote if you found this helpful.\nSUBQUERY:\n\nselect employee_id from Employees where employee_id not in (select employee_id from Salaries)\nunion \n | B_Sidhu | NORMAL | 2022-08-01T13:20:20.948558+00:00 | 2022-08-01T13:20:46.357550+00:00 | 2,474 | false | ### *Please Upvote if you found this helpful.*\n**SUBQUERY:**\n```\nselect employee_id from Employees where employee_id not in (select employee_id from Salaries)\nunion \nselect employee_id from Salaries where employee_id not in (select employee_id from Employees)\norder by employee_id;\n```\n\n**JOINS:**\n```\nselect e.employee_id from Employees e \nleft join Salaries s on e.employee_id=s.employee_id\nwhere salary is null \nunion \nselect s.employee_id from Salaries s\nleft join Employees e on e.employee_id=s.employee_id\nwhere name is null \norder by employee_id;\n``` | 28 | 0 | [] | 1 |
employees-with-missing-information | UNION and NOT IN CONCEPT | union-and-not-in-concept-by-ganjinaveen-666p | MYSQL\n\nselect employee_id from employees where employee_id not in (select employee_id from Salaries)\nunion \nselect employee_id from salaries where employee_ | GANJINAVEEN | NORMAL | 2023-04-19T13:30:44.972269+00:00 | 2023-04-19T13:30:44.972366+00:00 | 4,020 | false | # MYSQL\n``` \nselect employee_id from employees where employee_id not in (select employee_id from Salaries)\nunion \nselect employee_id from salaries where employee_id not in (select employee_id from employees)\norder by employee_id\n```\n# please upvote me it would encourage me alot\n | 24 | 0 | ['MySQL'] | 1 |
employees-with-missing-information | Simple and Easy MySQL Solutions (2 Approaches) | simple-and-easy-mysql-solutions-2-approa-quey | Approach 1\n\n#Using Join\nselect e.employee_id from Employees e\n left join Salaries s on e.employee_id = s.employee_id\n where s.salary is NULL \nuni | pruthashouche | NORMAL | 2022-07-06T10:16:26.094086+00:00 | 2022-07-06T10:16:26.094122+00:00 | 1,893 | false | Approach 1\n```\n#Using Join\nselect e.employee_id from Employees e\n left join Salaries s on e.employee_id = s.employee_id\n where s.salary is NULL \nunion\nselect s.employee_id from Salaries s\n left join Employees e on s.employee_id=e.employee_id\n where e.name is NULL\norder by employee_id;\n \n```\n\nApproach 2\n```\nselect employee_id from Employees where employee_id not in(select employee_id from Salaries)\nunion\nselect employee_id from Salaries where employee_id not in (select employee_id from Employees)\norder by employee_id;\n```\n\n**Please UpVote if it was Helpful :)** | 18 | 0 | ['MySQL'] | 1 |
employees-with-missing-information | simple solution(MSSQL) | simple-solutionmssql-by-naveen_2026-8qmj | 1.\n\nselect employee_id from employees\nunion\nselect employee_id from salaries\nexcept\nselect employee_id from employees\nintersect \nselect employee_id from | naveen_2026 | NORMAL | 2022-04-09T20:10:34.355277+00:00 | 2023-01-23T11:18:59.453996+00:00 | 1,930 | false | 1.\n```\nselect employee_id from employees\nunion\nselect employee_id from salaries\nexcept\nselect employee_id from employees\nintersect \nselect employee_id from salaries\n```\nunion of two tables minus intersection\n\nunion 1 2 4 5\nintersection 4 5 \nunion - intersection =1 2\n\n2.\n```\nselect employee_id from employees\nwhere employee_id not in (select employee_id from Salaries)\nunion\nselect employee_id from Salaries\nwhere employee_id not in (select employee_id from Employees)\n```\nplease upvote if you find it useful | 18 | 0 | ['MS SQL Server'] | 2 |
employees-with-missing-information | Oracle / MySQL 2WAYS Clean | oracle-mysql-2ways-clean-by-fllght-ooj0 | Oracle\n\nSELECT e.employee_id \n FROM Employees e \n LEFT JOIN Salaries s ON e.employee_id = s.employee_id\n WHERE s.salary IS NULL\n UNION\n SELECT s1.emp | FLlGHT | NORMAL | 2022-03-25T12:58:37.203642+00:00 | 2022-03-25T12:58:37.203830+00:00 | 1,369 | false | ### Oracle\n```\nSELECT e.employee_id \n FROM Employees e \n LEFT JOIN Salaries s ON e.employee_id = s.employee_id\n WHERE s.salary IS NULL\n UNION\n SELECT s1.employee_id\n FROM Salaries s1\n LEFT JOIN Employees e1 ON e1.employee_id = s1.employee_id\n WHERE e1.name IS NULL\n```\n\n### MySQL\n\n```\nSELECT employee_id \n FROM Salaries \n WHERE employee_id NOT IN (SELECT employee_id \n FROM Employees\n )\nUNION\nSELECT employee_id \n FROM Employees \n WHERE employee_id NOT IN (SELECT employee_id \n FROM Salaries\n )\nORDER BY 1\n``` | 15 | 0 | ['MySQL', 'Oracle'] | 0 |
employees-with-missing-information | Union | union-by-linyang0925-gman | select T.employee_id \n from\n (select * from Employees\n union \n select * from Salaries) as T\n group by T.employee_id \n having count(employee_id)<2\n order | Linyang0925 | NORMAL | 2021-09-09T23:29:20.581495+00:00 | 2021-09-09T23:29:20.581539+00:00 | 1,631 | false | select T.employee_id \n from\n (select * from Employees\n union \n select * from Salaries) as T\n group by T.employee_id \n having count(employee_id)<2\n order by employee_id asc\n | 13 | 0 | [] | 0 |
employees-with-missing-information | Simple MySQL Solution | 2 Approaches | Easy to understand | Faster than 99% | simple-mysql-solution-2-approaches-easy-tlt4h | \n# Note: Full Outer Join is not supported by MySQL so we have to use left and right join with union in the below solution.\nselect employee_id from\n(select em | deb_dutta_ | NORMAL | 2022-04-06T14:04:22.761828+00:00 | 2022-04-06T14:06:17.543678+00:00 | 1,459 | false | ```\n# Note: Full Outer Join is not supported by MySQL so we have to use left and right join with union in the below solution.\nselect employee_id from\n(select emp.employee_id\nfrom employees emp left join salaries sal \non emp.employee_id = sal.employee_id\nwhere salary is null\nUNION\nselect sal.employee_id\nfrom employees emp right join salaries sal \non emp.employee_id = sal.employee_id\nwhere emp.name is null) temp\norder by employee_id\n\n# Faster Solution\nselect employee_id from\n(select employee_id from employees\nwhere employee_id NOT IN (select employee_id from salaries)\nUNION\nselect employee_id from salaries\nwhere employee_id NOT IN (select employee_id from employees)) temp\norder by employee_id\n\n# Do upvote if you like both the approaches\n``` | 12 | 0 | ['MySQL'] | 2 |
employees-with-missing-information | MySQL | 3 Different approaches | mysql-3-different-approaches-by-patil_pr-hb4k | \n# Solution 1\n\nSELECT employee_id \nFROM Salaries \nWHERE employee_id NOT IN (SELECT employee_id \n FROM Employees\n | patil_pratik | NORMAL | 2022-06-11T01:56:54.850621+00:00 | 2022-06-11T01:56:54.850649+00:00 | 1,326 | false | \n# Solution 1\n```\nSELECT employee_id \nFROM Salaries \nWHERE employee_id NOT IN (SELECT employee_id \n FROM Employees\n )\nUNION\n\nSELECT employee_id \nFROM Employees \nWHERE employee_id NOT IN (SELECT employee_id \n FROM Salaries\n )\nORDER BY employee_id\n```\n\n# Solution 2\n```\nSELECT T.employee_id from\n(\n SELECT * FROM Employees \n UNION ALL\n SELECT * FROM Salaries\n) T\n\nGROUP BY T.EMPLOYEE_ID\nHAVING COUNT(T.EMPLOYEE_ID) = 1 /*can also use count(*) */\nORDER BY T.EMPLOYEE_ID ASC\n```\n\n# Solution 3\nNote - Doesn\'t work here in LEETCODE but this is also a potenstial solutin to solve this problem during interviews.\n\n```\nSELECT ISNULL(A.employee_id,B.employee_id) AS employee_id\nFROM Employees A\nFULL OUTER JOIN Salaries B\nON A.employee_id = B.employee_id\nWHERE A.name IS NULL OR B.salary IS NULL\nORDER BY employee_id\n``` | 11 | 0 | ['Union Find', 'MySQL'] | 2 |
employees-with-missing-information | SOLUTION WITH SIMPLE QUERY FULL JOIN( SQL SERVER ) | solution-with-simple-query-full-join-sql-fqmn | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | cooking_Guy_9ice | NORMAL | 2023-03-06T14:13:55.925545+00:00 | 2023-03-06T14:13:55.925597+00:00 | 781 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/* Write your T-SQL query statement below */\n\nSELECT\n ISNULL(E.employee_id,s.employee_id) employee_id\nFROM\n Employees E\nFULL JOIN \n Salaries S ON E.employee_id = S.employee_id\nWHERE\n E.name IS NULL\nOR\n S.salary IS NULL\nORDER BY\n ISNULL(E.employee_id,s.employee_id)\n``` | 10 | 0 | ['MS SQL Server'] | 0 |
employees-with-missing-information | pandas || xor, with explanation || T/S: 98% / 97% | pandas-xor-with-explanation-ts-98-97-by-172b2 | Here\'s the plan:\n\n- We convert the two series employees.employee_idand salaries.employee_id to sets.\n\n- The employees with missing information are exactly | Spaulding_ | NORMAL | 2023-10-25T23:12:54.652688+00:00 | 2023-10-27T00:03:34.595958+00:00 | 395 | false | Here\'s the plan:\n\n- We convert the two series `employees.employee_id`and `salaries.employee_id` to sets.\n\n- The employees with missing information are exactly those in one set but not both. Thus, we take the `xor` of the two sets, convert that set to a sorted list, and return that set in a frame.\n```\nimport pandas as pd\n\ndef find_employees(employees: pd.DataFrame, salaries: pd.DataFrame) -> pd.DataFrame:\n\n return pd.DataFrame({\'employee_id\':sorted(set(employees.employee_id) ^\n set(salaries .employee_id))})\n```\n[https://leetcode.com/problems/employees-with-missing-information/submissions/1084180417/](http://)\n\nPython 3 || xor, with explanation || T/S: 98% / 97%\n\nI could be wrong, but I think that time complexity is *O*(*N*) and space complexity is *O*(*N*), in which *N* ~ the greater of the number of rows in the two given frames. | 9 | 0 | ['Pandas'] | 1 |
employees-with-missing-information | By using UNION operation in mysql | by-using-union-operation-in-mysql-by-shi-8gaq | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | Shivani_2802 | NORMAL | 2023-01-29T17:37:59.362540+00:00 | 2023-01-29T17:37:59.362574+00:00 | 2,230 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nSELECT employee_id from Employees e WHERE employee_id not in (Select employee_id from Salaries)\nUNION \nSELECT employee_id from Salaries s WHERE employee_id not in (Select employee_id from Employees)\nORDER BY employee_id;\n``` | 9 | 0 | ['MySQL'] | 2 |
employees-with-missing-information | Fast MySQL solution using UNION and GROUP BY with brief explanation | fast-mysql-solution-using-union-and-grou-6k1c | Steps:\n1. select all the employee_ids from 2 tables\n2. find out the employee_id which appears only once\n\nfor example:\ntable 1=[1,2,5], table 2=[1,4,5]\nSte | eminem18753 | NORMAL | 2021-08-08T09:58:00.371576+00:00 | 2021-08-08T10:13:32.700524+00:00 | 1,922 | false | Steps:\n1. select all the employee_ids from 2 tables\n2. find out the employee_id which appears only once\n\nfor example:\ntable 1=[1,2,5], table 2=[1,4,5]\nStep 1. select all the employee_ids with UNION ALL\n-> 1, 1, 2, 4, 5, 5\nStep 2. find those employee_ids which appear only once\n-> 2, 4\n```\n# Write your MySQL query statement below\nSELECT employee_id FROM\n(\n\t# select all the employee_ids from 2 tables (eg. [1, 1, 2, 4, 5, 5])\n SELECT employee_id FROM Employees\n UNION ALL SELECT employee_id FROM Salaries\n) t\nGROUP BY employee_id\nHAVING COUNT(*)=1\nORDER BY employee_id;\n``` | 9 | 0 | [] | 2 |
employees-with-missing-information | SQL sloution | sql-sloution-by-abdullakh-kmqm | Code\n\nSELECT employee_id FROM Employees WHERE employee_id not in (SELECT employee_id FROM Salaries)\n UNION\nSELECT employee_id FROM Salaries\n WHERE emplo | abdullakh | NORMAL | 2023-01-16T05:41:41.626485+00:00 | 2023-01-16T05:41:41.626529+00:00 | 1,468 | false | # Code\n```\nSELECT employee_id FROM Employees WHERE employee_id not in (SELECT employee_id FROM Salaries)\n UNION\nSELECT employee_id FROM Salaries\n WHERE employee_id NOT IN (SELECT employee_id FROM Employees)\nORDER BY employee_id\n``` | 8 | 0 | ['Oracle'] | 0 |
employees-with-missing-information | MSSQL: simple solution via full outer join | mssql-simple-solution-via-full-outer-joi-v3ma | Hi, there! \nTo solve this problem, you need to take the following steps:\n1. Simply join the two tables (sets) with a full outer join;\n2. Add tuple filterin | makhlov | NORMAL | 2022-05-09T15:19:19.794182+00:00 | 2022-05-09T15:19:19.794209+00:00 | 986 | false | Hi, there! \nTo solve this problem, you need to take the following steps:\n1. Simply join the two tables (sets) with a [*full outer join*](https://www.w3schools.com/sql/sql_join_full.asp);\n2. Add tuple filtering condition to where:\n```1 = 1``` used to make it easier to remove conditions through a "--" comment\n```and E.[name] is null``` because we need employees without names\n```or S.[salary] is null``` ...or without salaries;\n3. Now we need to display the ID of the employee who has *null* in one of the tables (*Employees* OR *Salaries*). To do this, we use *[coalesce](https://docs.microsoft.com/en-us/sql/t-sql/language-elements/coalesce-transact-sql?view=sql-server-ver15)*. In short, function ```coalesce(E.[employee_id], S.[employee_id])``` in this case substitutes the value of the second argument if the first argument is NULL.\n4. Finally, we just sort the *coalesce* function result, because by description, we must return the result in ascending order.\n\n```\nselect\n coalesce(E.[employee_id], S.[employee_id]) as \'employee_id\'\nfrom [dbo].[Employees] E\n full outer join [dbo].[Salaries] S\n on E.[employee_id] = S.[employee_id]\nwhere 1 = 1\n and E.[name] is null\n or S.[salary] is null\norder by \'employee_id\';\n``` | 8 | 0 | ['MS SQL Server'] | 0 |
employees-with-missing-information | ✅✅Easy || By Union || Order BY || NOT IN | easy-by-union-order-by-not-in-by-arpit50-9cmp | \n(\n SELECT e2.employee_id FROM salaries AS e2 \nWHERE e2.employee_id NOT IN (SELECT Employees.employee_id FROM Employees)\nUNION\nSELECT e1.employee_id FRO | Arpit507 | NORMAL | 2022-09-25T07:13:00.748741+00:00 | 2022-09-25T07:13:00.748786+00:00 | 907 | false | ```\n(\n SELECT e2.employee_id FROM salaries AS e2 \nWHERE e2.employee_id NOT IN (SELECT Employees.employee_id FROM Employees)\nUNION\nSELECT e1.employee_id FROM Employees e1 WHERE\ne1.employee_id NOT IN (SELECT Salaries.employee_id FROM Salaries)\n) ORDER BY employee_id\n# atlast order by employee_id\n``` | 7 | 0 | ['Union Find', 'MySQL', 'Oracle'] | 0 |
employees-with-missing-information | 1965. Employees With Missing Information | 1965-employees-with-missing-information-uftd4 | \nSELECT employee_id FROM Employees\nWHERE employee_id NOT IN (SELECT employee_id FROM Salaries)\n\nUNION\n\nSELECT employee_id FROM Salaries\nWHERE employee_id | Spaulding_ | NORMAL | 2022-09-21T20:19:04.133217+00:00 | 2022-09-21T20:19:04.133253+00:00 | 686 | false | ```\nSELECT employee_id FROM Employees\nWHERE employee_id NOT IN (SELECT employee_id FROM Salaries)\n\nUNION\n\nSELECT employee_id FROM Salaries\nWHERE employee_id NOT IN (SELECT employee_id FROM Employees)\n\nORDER BY employee_id;\n``` | 7 | 0 | ['MySQL'] | 0 |
employees-with-missing-information | 1965. Employees With Missing Information | 1965-employees-with-missing-information-rw8fq | ```\nSELECT employee_id FROM Employees\nWHERE employee_id NOT IN (SELECT employee_id FROM Salaries)\n\nUNION\n\nSELECT employee_id FROM Salaries\nWHERE employee | Spaulding_ | NORMAL | 2022-09-08T08:06:57.286437+00:00 | 2022-09-08T08:06:57.286479+00:00 | 193 | false | ```\nSELECT employee_id FROM Employees\nWHERE employee_id NOT IN (SELECT employee_id FROM Salaries)\n\nUNION\n\nSELECT employee_id FROM Salaries\nWHERE employee_id NOT IN (SELECT employee_id FROM Employees)\n\nORDER BY employee_id; | 7 | 0 | ['MySQL'] | 0 |
employees-with-missing-information | Easy |FULL OUTER JOIN | MS SQL | without union | easy-full-outer-join-ms-sql-without-unio-tpst | It will work on ms sql.\n\nSELECT (CASE \n WHEN e.employee_id IS null \n THEN s.employee_id \n ELSE e.employee_id \n END | rishav_1570 | NORMAL | 2022-08-25T19:51:06.709849+00:00 | 2022-08-25T19:51:06.709889+00:00 | 866 | false | It will work on ms sql.\n```\nSELECT (CASE \n WHEN e.employee_id IS null \n THEN s.employee_id \n ELSE e.employee_id \n END) AS employee_id \nFROM employees e \nFULL OUTER JOIN salaries s \n ON s.employee_id=e.employee_id\nWHERE e.name IS null \n OR s.salary IS null\nORDER BY employee_id;\n``` | 7 | 0 | [] | 1 |
employees-with-missing-information | Pandas outer join | pandas-outer-join-by-1v9n418vn51-x5d8 | Intuition\n1. Merge two tables\n2. Select rows with at least one null\n\n\n# Code\n\nimport pandas as pd\n\ndef find_employees(employees: pd.DataFrame, salaries | 1v9n418vn51 | NORMAL | 2023-08-11T19:10:57.415748+00:00 | 2023-08-11T19:10:57.415768+00:00 | 273 | false | # Intuition\n1. Merge two tables\n2. Select rows with at least one null\n\n\n# Code\n```\nimport pandas as pd\n\ndef find_employees(employees: pd.DataFrame, salaries: pd.DataFrame) -> pd.DataFrame:\n df = pd.merge(employees, salaries, on=\'employee_id\', how=\'outer\')\n return df[df.isna().any(axis=1)][[\'employee_id\']].sort_values(by=\'employee_id\')\n``` | 6 | 0 | ['Pandas'] | 0 |
employees-with-missing-information | Beginner friendly solution | beginner-friendly-solution-by-himanshubh-uu4s | \n# Write your MySQL query statement below\nselect employee_id from Employees where employee_id not in(select employee_id from Salaries)\nunion\nselect employee | HimanshuBhoir | NORMAL | 2022-06-04T01:51:38.696861+00:00 | 2022-06-04T01:51:38.696885+00:00 | 566 | false | ```\n# Write your MySQL query statement below\nselect employee_id from Employees where employee_id not in(select employee_id from Salaries)\nunion\nselect employee_id from Salaries where employee_id not in(select employee_id from Employees)\norder by employee_id asc\n``` | 6 | 0 | ['MySQL'] | 0 |
employees-with-missing-information | MS SQL | ms-sql-by-siyu14-5038 | Question\n\n1965. Employees With Missing Information\nEasy\n\nSQL Schema\nTable: Employees\n\n+-------------+---------+\n| Column Name | Type |\n+----------- | siyu14 | NORMAL | 2021-10-16T16:44:23.890218+00:00 | 2023-05-31T05:44:20.513816+00:00 | 557 | false | #### Question\n```\n1965. Employees With Missing Information\nEasy\n\nSQL Schema\nTable: Employees\n\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| employee_id | int |\n| name | varchar |\n+-------------+---------+\nemployee_id is the primary key for this table.\nEach row of this table indicates the name of the employee whose ID is employee_id.\n \n\nTable: Salaries\n\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| employee_id | int |\n| salary | int |\n+-------------+---------+\nemployee_id is the primary key for this table.\nEach row of this table indicates the salary of the employee whose ID is employee_id.\n \n\nWrite an SQL query to report the IDs of all the employees with missing information. The information of an employee is missing if:\n\nThe employee\'s name is missing, or\nThe employee\'s salary is missing.\nReturn the result table ordered by employee_id in ascending order.\n\nThe query result format is in the following example:\n\n \n\nEmployees table:\n+-------------+----------+\n| employee_id | name |\n+-------------+----------+\n| 2 | Crew |\n| 4 | Haven |\n| 5 | Kristian |\n+-------------+----------+\nSalaries table:\n+-------------+--------+\n| employee_id | salary |\n+-------------+--------+\n| 5 | 76071 |\n| 1 | 22517 |\n| 4 | 63539 |\n+-------------+--------+\n\nResult table:\n+-------------+\n| employee_id |\n+-------------+\n| 1 |\n| 2 |\n+-------------+\n\nEmployees 1, 2, 4, and 5 are working at this company.\nThe name of employee 1 is missing.\nThe salary of employee 2 is missing.\n```\n#### Answer1\n```SQL\nselect case when e.employee_id is NULL then s.employee_id\nelse e.employee_id end as employee_id FROM Employees e\nFULL OUTER JOIN Salaries s\nON e.employee_id = s.employee_id\nWHERE e.employee_id IS NULL or s.employee_id IS NULL \norder by employee_id\n```\n#### Answer2\n```SQL\nselect coalesce(e.employee_id,s.employee_id) as employee_id \nFROM Employees e\nFULL OUTER JOIN Salaries s\nON e.employee_id = s.employee_id\nWHERE e.employee_id IS NULL or s.employee_id IS NULL \norder by employee_id\n\n``` | 6 | 1 | ['MS SQL Server'] | 2 |
employees-with-missing-information | Simple MySQL solution using NOT IN | simple-mysql-solution-using-not-in-by-em-paux | \n# Write your MySQL query statement below\nSELECT employee_id FROM Employees\nWHERE employee_id NOT IN (SELECT employee_id FROM Salaries)\nUNION SELECT employe | eminem18753 | NORMAL | 2021-08-08T10:11:24.213050+00:00 | 2021-08-08T10:13:23.200773+00:00 | 1,500 | false | ```\n# Write your MySQL query statement below\nSELECT employee_id FROM Employees\nWHERE employee_id NOT IN (SELECT employee_id FROM Salaries)\nUNION SELECT employee_id FROM Salaries\nWHERE employee_id NOT IN (SELECT employee_id FROM Employees)\nORDER BY employee_id;\n``` | 6 | 0 | [] | 0 |
employees-with-missing-information | Simple Solution using Full Join | simple-solution-using-full-join-by-danie-l81c | \n# Approach\n Describe your approach to solving the problem. \nFor this we should know the FULL JOIN Combination of RIGHT and LEFT join, In first solution used | Daniel_Charles_J | NORMAL | 2024-09-11T08:43:12.350514+00:00 | 2024-09-11T08:43:12.350549+00:00 | 376 | false | \n# Approach\n<!-- Describe your approach to solving the problem. -->\nFor this we should know the FULL JOIN Combination of RIGHT and LEFT join, In first solution used FULL JOIN directly, In second Solution showed how it is working without FULL JOIN. Both will work.\n\n\n# Code\n```postgresql []\n-- Write your PostgreSQL query statement below\nSELECT COALESCE(t1.employee_id, t2.employee_id) AS employee_id\nFROM Employees t1 FULL JOIN Salaries t2\nON t1.employee_id = t2.employee_id\nWHERE t1.name IS NULL OR t2.salary IS NULL\nORDER BY employee_id \n```\n\n\n# Code\n```postgresql []\n-- Write your PostgreSQL query statement below\nWITH temp as (SELECT e.employee_id as emplyee_id_1, e.name as name_1, s.employee_id as employee_id_2, s.salary as salary FROM Employees e LEFT JOIN Salaries s ON e.employee_id = s.employee_id\nUNION\nSELECT e.employee_id as emplyee_id_1, e.name as name_1, s.employee_id as employee_id_2, s.salary as salary FROM Employees e RIGHT JOIN Salaries s ON e.employee_id = s.employee_id)\n\nSELECT COALESCE(emplyee_id_1, employee_id_2) as employee_id FROM temp WHERE emplyee_id_1 IS NULL OR name_1 IS NULL OR employee_id_2 IS NULL OR salary IS NULL ORDER BY 1\n``` | 5 | 0 | ['PostgreSQL'] | 1 |
employees-with-missing-information | SQL Server CLEAN & EASY | sql-server-clean-easy-by-rhazem13-ugxh | \nSELECT e.employee_id\nFROM Employees e\nLEFT JOIN Salaries s ON e.employee_id = s.employee_id\nWHERE e.name IS NULL OR s.salary IS NULL\nUNION\nSELECT s.emplo | rhazem13 | NORMAL | 2023-03-16T12:28:26.577091+00:00 | 2023-03-16T12:28:26.577137+00:00 | 1,616 | false | ```\nSELECT e.employee_id\nFROM Employees e\nLEFT JOIN Salaries s ON e.employee_id = s.employee_id\nWHERE e.name IS NULL OR s.salary IS NULL\nUNION\nSELECT s.employee_id\nFROM Employees e\nRIGHT JOIN Salaries s ON e.employee_id = s.employee_id\nWHERE e.employee_id IS NULL OR e.name IS NULL\nORDER BY employee_id ASC;\n``` | 5 | 0 | [] | 0 |
employees-with-missing-information | easy union operation | easy-union-operation-by-nancy25-trpe | please upvote if you liked\n\n# Write your MySQL query statement below\nselect employee_id from Employees where\nemployee_id not in (select employee_id from Sal | nancy25 | NORMAL | 2022-11-08T12:01:39.303736+00:00 | 2022-11-08T12:01:39.303770+00:00 | 638 | false | **please upvote if you liked**\n```\n# Write your MySQL query statement below\nselect employee_id from Employees where\nemployee_id not in (select employee_id from Salaries)\nunion \nselect employee_id from Salaries where\nemployee_id not in (select employee_id from Employees) \norder by employee_id\n``` | 5 | 0 | ['MySQL'] | 1 |
employees-with-missing-information | SQL | Easy INNER JOIN & UNION | sql-easy-inner-join-union-by-tejkiran_1-19no | \nSELECT employee_id FROM employees\nWHERE employee_id NOT IN (SELECT employee_id FROM salaries)\nUNION\nSELECT employee_id FROM salaries\nWHERE employee_id NOT | tejkiran_1 | NORMAL | 2022-09-27T04:17:30.288731+00:00 | 2022-09-27T04:17:30.288775+00:00 | 949 | false | ```\nSELECT employee_id FROM employees\nWHERE employee_id NOT IN (SELECT employee_id FROM salaries)\nUNION\nSELECT employee_id FROM salaries\nWHERE employee_id NOT IN (SELECT employee_id FROM employees)\nORDER BY employee_id;\n\n``` | 5 | 0 | ['Union Find', 'MySQL'] | 0 |
employees-with-missing-information | ✅MySQL || Beginner level ||Easy to Understand||Simple-Short -Solution✅ | mysql-beginner-level-easy-to-understands-k1sw | Please upvote to motivate me in my quest of documenting all leetcode solutions. HAPPY CODING:)\nAny suggestions and improvements are always welcome.\n========== | Anos | NORMAL | 2022-09-02T19:27:11.838788+00:00 | 2022-09-02T19:27:11.838832+00:00 | 505 | false | **Please upvote to motivate me in my quest of documenting all leetcode solutions. HAPPY CODING:)\nAny suggestions and improvements are always welcome.***\n*====================================================================*\n\u2705 **MySQL Code :**\n```\nSELECT employee_id FROM Employees WHERE employee_id NOT IN (SELECT employee_id FROM Salaries)\nUNION \nSELECT employee_id FROM Salaries WHERE employee_id NOT IN (SELECT employee_id FROM Employees)\nORDER BY 1 ASC;\n```\n**Runtime:** 882 ms\n**Memory Usage:** 0B\n________________________________\n__________________________________\n\nIf you like the solution, please upvote \uD83D\uDD3C\nFor any questions, or discussions, comment below. \uD83D\uDC47\uFE0F | 5 | 0 | ['Union Find', 'MySQL'] | 0 |
employees-with-missing-information | ✅ 🔥 MySQL || ⚡easy solution | mysql-easy-solution-by-maary-y8ig | \nselect employee_id from employees \nwhere employee_id not in (select employee_id from salaries)\nunion\nselect employee_id from salaries\nwhere employee_id no | maary_ | NORMAL | 2022-08-22T18:13:59.468160+00:00 | 2023-06-02T16:37:20.319140+00:00 | 425 | false | ```\nselect employee_id from employees \nwhere employee_id not in (select employee_id from salaries)\nunion\nselect employee_id from salaries\nwhere employee_id not in (select employee_id from employees)\norder by 1\n``` | 5 | 0 | ['Union Find', 'MySQL'] | 0 |
employees-with-missing-information | ✅ ✅ Best Solution and Best Explanation. Please Once Try it | best-solution-and-best-explanation-pleas-o55o | Please Upvote if You Love it \u2705\n\n\n# Write your MySQL query statement below\n\n# Query 1: => For finding ids of all the employees with missing salary, we | vikramsinghgurjar | NORMAL | 2022-07-20T20:44:30.437336+00:00 | 2022-07-20T20:46:02.603487+00:00 | 358 | false | ### Please Upvote if You Love it \u2705\n\n```\n# Write your MySQL query statement below\n\n# Query 1: => For finding ids of all the employees with missing salary, we need to query for employees whose records are present in employees table but not in salaries tables. So Query 1 will be following\n\n\tSelect employee_id from Employees where employee_id not in (Select employee_id from Salaries )\n\n# Query 2 : => For finding ids of all the employees with missing name, we need to query for employees whose records are present in Salaries table but not in Employees tables. So Query 2 Will be following \n\n\tSelect employee_id from Salaries where employee_id not in (Select employee_id from Employees)\n\n# For finding employee_id of all the employees with missing information we need to take Union (OR condition ) of Query 1 and Query 2 and then order it in ascending order\n\n# Final Solution is\nSelect employee_id from Employees where employee_id not in (Select employee_id from Salaries )\nUnion\nSelect employee_id from Salaries where employee_id not in (Select employee_id from Employees)\norder by employee_id asc\n``` | 5 | 0 | ['Union Find'] | 1 |
employees-with-missing-information | Oracle Simple And Best Solution | oracle-simple-and-best-solution-by-ruthv-4q5a | Please upvote if you find it helpful.\n\n/* Write your PL/SQL query statement below */\n\nSELECT employee_id FROM employees e\nFULL OUTER JOIN\nsalaries s\nUSIN | ruthvikc27-dev | NORMAL | 2022-07-15T14:19:37.315044+00:00 | 2022-07-15T14:19:37.315092+00:00 | 319 | false | # Please upvote if you find it helpful.\n```\n/* Write your PL/SQL query statement below */\n\nSELECT employee_id FROM employees e\nFULL OUTER JOIN\nsalaries s\nUSING (employee_id)\nWHERE e.name IS NULL OR s.salary IS NULL\nORDER BY employee_id;\n``` | 5 | 0 | ['MySQL', 'Oracle'] | 0 |
employees-with-missing-information | Oracle 820 ms two solution + explanation | oracle-820-ms-two-solution-explanation-b-9hcn | Solution 1:\n1. Union IDs from both table (with saving duplicates)\n2. Select IDs from step 1 that occur once (IDs with name and salary will have duplicates)\n3 | deigumnov | NORMAL | 2022-04-15T08:22:04.078015+00:00 | 2022-04-15T08:22:04.078048+00:00 | 274 | false | **Solution 1:**\n1. Union IDs from both table (with saving duplicates)\n2. Select IDs from step 1 that occur once (IDs with name and salary will have duplicates)\n3. Sort IDs from step 2\n```\nselect employee_id from (\n select employee_id from employees\n union all\n select employee_id from salaries\n) tmp\ngroup by employee_id\nhaving count(employee_id) = 1\norder by employee_id\n```\n\n**Solution 2:**\n1. Find IDs from first table, thats not occur in second table\n2. Find IDs from second table, thats not occur in first table\n3. Union results from previous steps\n4. Sort IDs from step 3\n```\nselect employee_id from (\n select e.employee_id from employees e\n left join salaries s on e.employee_id = s.employee_id\n where s.employee_id is NULL\n union all\n select s.employee_id from employees e\n right join salaries s on e.employee_id = s.employee_id\n where e.employee_id is NULL\n) tmp\norder by employee_id\n``` | 5 | 0 | ['Union Find', 'Oracle'] | 1 |
employees-with-missing-information | 🔥🔥🔥3 solutions in MySQL | Beats 95.47%🔥🔥🔥 | 3-solutions-in-mysql-beats-9547-by-prito-1fsl | 1. Brute force solution with sub-query with runtime 1071ms beats 40.57%
Time complexity: O(N * M)
Space complexity: O(N + M + R) => N = total rows from first | pritom5928 | NORMAL | 2025-02-20T07:08:15.869967+00:00 | 2025-02-20T07:08:15.869967+00:00 | 342 | false | # 1. Brute force solution with sub-query with runtime 1071ms beats 40.57%
- Time complexity: O(N * M)
- Space complexity: O(N + M + R) => N = total rows from first sub-query, M= Total rows from second sub-query, R = total rows after UNION
# Code
```mysql []
SELECT
employee_id
FROM employees
WHERE employee_id NOT IN (
SELECT
employee_id
FROM salaries
)
UNION
SELECT
employee_id
FROM salaries
WHERE employee_id NOT IN
(SELECT
employee_id
FROM employees
)
ORDER BY employee_id;
```
# 2. Solution with Join with runtime 1184ms beats 29.10%
- Time complexity: O(M × N) + O(N × M) + O(K log K) => union & order by costs O(K log K)
- Space complexity: O(M × N)
# Code
```mysql []
SELECT
e.employee_id
FROM employees e
LEFT JOIN salaries s ON e.employee_id = s.employee_id
WHERE s.employee_id IS NULL
UNION
SELECT
s.employee_id
FROM salaries s
LEFT JOIN employees e ON e.employee_id = s.employee_id
WHERE e.employee_id IS NULL
ORDER BY employee_id;
```
# 3. Optimal solution with Correlated sub-query with runtime 556ms beats 95.47%
- Time complexity: O(M × N)
- Space complexity: O(K) => K is the number of rows of unmatched employees in both table
# Code
```mysql []
SELECT
e.employee_id
FROM employees e
WHERE NOT EXISTS(
SELECT
1
FROM salaries s
WHERE e.employee_id = s.employee_id
)
UNION
SELECT
s.employee_id
FROM salaries s
WHERE NOT EXISTS(
SELECT
1
FROM
employees e
WHERE
e.employee_id = s.employee_id
)
ORDER BY employee_id;
``` | 4 | 0 | ['Database', 'MySQL'] | 0 |
employees-with-missing-information | Fast and Simple Solution by using group by and count | fast-and-simple-solution-by-using-group-6zs9m | Problem Statement\nGiven two tables Employees and Salaries, where Employees has columns employee_id and name, and Salaries has columns employee_id and salary, t | OnDecember | NORMAL | 2023-12-23T11:36:10.592128+00:00 | 2023-12-23T11:36:10.592150+00:00 | 446 | false | # Problem Statement\nGiven two tables `Employees` and `Salaries`, where `Employees` has columns `employee_id` and `name`, and `Salaries` has columns `employee_id` and `salary`, the task is to retrieve the `employee_id` of employees who appear in either `Employees` or `Salaries` table but not in both.\n\n## Intuition\nThe problem involves identifying unique `employee_id` values that are present in either `Employees` or `Salaries` but not in both.\n\n## Approach\n1. **Use of `UNION ALL`:**\n - Utilize the `UNION ALL` operator to combine the rows from both tables (`Employees` and `Salaries`) into a single result set.\n - The `UNION ALL` operator is used to include duplicates if any exist.\n\n2. **Grouping and Filtering:**\n - Create a subquery (`t`) to represent the combined result set.\n - Use the `GROUP BY` clause on `employee_id` to group the results based on unique employee identifiers.\n - Use the `HAVING` clause to filter out rows where the count of occurrences for an `employee_id` is less than 2, indicating that the employee is present in either `Employees` or `Salaries` but not in both.\n\n3. **Ordering Results:**\n - Use the `ORDER BY` clause to order the final result set based on `employee_id`.\n\n## Complexity\n- **Time complexity:**\n - The time complexity is primarily determined by the use of `UNION ALL` and the grouping operation. It is generally efficient and can be considered as $$O(n)$$, where $$n$$ is the total number of rows in both tables.\n\n- **Space complexity:**\n - The space complexity is also $$O(n)$$, where $$n$$ is the total number of rows in both tables. This accounts for the storage of intermediate results during the use of `UNION ALL` and the grouping operation.\n\n# Code\n```\n# Write your MySQL query statement below\nSELECT employee_id\nFROM (\n SELECT *\n FROM Employees\n UNION ALL \n SELECT *\n FROM Salaries\n) AS t\nGROUP BY employee_id\nHAVING COUNT(*) < 2\nORDER BY employee_id \n```\n\n | 4 | 0 | ['MySQL'] | 0 |
employees-with-missing-information | MYSQL | UNION | NOT IN | ORDER BY | mysql-union-not-in-order-by-by-venkat089-h2ol | \n# Write your MySQL query statement below\nselect employee_id from \nEmployees where employee_id not in (select employee_id from Salaries)\nunion\nselect emplo | Venkat089 | NORMAL | 2022-11-08T06:35:29.468968+00:00 | 2022-11-08T06:35:29.469018+00:00 | 1,155 | false | ```\n# Write your MySQL query statement below\nselect employee_id from \nEmployees where employee_id not in (select employee_id from Salaries)\nunion\nselect employee_id from\nSalaries where employee_id not in (select employee_id from Employees)\norder by employee_id asc;\n``` | 4 | 0 | ['Union Find', 'MySQL'] | 0 |
employees-with-missing-information | Clever Oracle Solution With NVL() function | clever-oracle-solution-with-nvl-function-jlsi | There is a NVL(param1, param2) function in oracle which comes in handy when we want to replace the NULL value with another value. Here if the value of param1 is | Abbos_Akramov | NORMAL | 2022-11-04T11:04:42.715217+00:00 | 2022-11-04T11:04:42.715258+00:00 | 1,030 | false | There is a NVL(param1, param2) function in oracle which comes in handy when we want to replace the NULL value with another value. Here if the value of param1 is null, then it is replaced with the value of param2. \n\n\n```\nSELECT NVL(E.EMPLOYEE_ID, S.EMPLOYEE_ID) AS EMPLOYEE_ID \nFROM EMPLOYEES E\nFULL JOIN SALARIES S ON E.EMPLOYEE_ID = S.EMPLOYEE_ID\nWHERE E.NAME IS NULL\nOR S.SALARY IS NULL \nORDER BY EMPLOYEE_ID;\n``` | 4 | 0 | ['Oracle'] | 0 |
employees-with-missing-information | MySQL SHORTEST Solution | mysql-shortest-solution-by-yassineammani-2lqa | This is the shortest solution ever \n\nSELECT employee_id FROM Employees\nWHERE employee_id NOT IN (SELECT employee_id FROM Salaries)\nUNION\nSELECT employee_id | YassineAmmani | NORMAL | 2022-09-10T14:48:28.261823+00:00 | 2022-09-10T14:48:52.814435+00:00 | 248 | false | This is the shortest solution ever \n```\nSELECT employee_id FROM Employees\nWHERE employee_id NOT IN (SELECT employee_id FROM Salaries)\nUNION\nSELECT employee_id FROM Salaries \nWHERE employee_id NOT IN (SELECT employee_id FROM Employees)\nORDER BY employee_id\n```\n\n***Please UPVOTE*** | 4 | 0 | ['Union Find', 'MySQL'] | 0 |
employees-with-missing-information | using UNION And LEFT JOIN |EASY | using-union-and-left-join-easy-by-rishhh-9w3x | \n\'\'\'\n\n# Write your MySQL query statement below\nSELECT Salaries.employee_id\nFROM Salaries \nLEFT JOIN Employees \n on Employees.employee_id=Salaries. | Rishhh101 | NORMAL | 2022-07-15T03:24:10.226211+00:00 | 2022-07-15T03:24:10.226241+00:00 | 173 | false | \n\'\'\'\n\n# Write your MySQL query statement below\nSELECT Salaries.employee_id\nFROM Salaries \nLEFT JOIN Employees \n on Employees.employee_id=Salaries.employee_id\nWHERE Employees.name is null\n\nunion\n\nSELECT Employees.employee_id\nFROM Employees\nLEFT JOIN Salaries\n on Salaries.employee_id=Employees.employee_id\nWHERE Salaries.salary is null\n\norder by employee_id\n\n \n \n\t\n\'\'\' | 4 | 0 | [] | 0 |
employees-with-missing-information | Easiest mysql solution!!!!!!!!!!!! | easiest-mysql-solution-by-rajwardhan22-0zdv | \nselect employees.employee_id from employees left join salaries on\nemployees.employee_id=salaries.employee_id\nwhere salaries.employee_id is null \n\nunion\n\ | Rajwardhan22 | NORMAL | 2022-05-13T18:43:10.241327+00:00 | 2022-05-13T18:43:10.241348+00:00 | 461 | false | ```\nselect employees.employee_id from employees left join salaries on\nemployees.employee_id=salaries.employee_id\nwhere salaries.employee_id is null \n\nunion\n\nselect salaries.employee_id from salaries left join employees on\nemployees.employee_id=salaries.employee_id\nwhere employees.employee_id is null \n\norder by employee_id asc\n``` | 4 | 0 | ['Union Find', 'MySQL'] | 0 |
employees-with-missing-information | UNION vs UNION ALL discussion | Two approaches to solve the problem | Description | union-vs-union-all-discussion-two-approa-h8g8 | Before moving on to SQL queries let\'s dicuss what union and union all does\n UNION does a union without duplicates\n UNION ALL takes into account duplicates as | swapnildarmora | NORMAL | 2022-04-20T14:10:42.641199+00:00 | 2022-04-21T05:00:47.237740+00:00 | 243 | false | Before moving on to SQL queries let\'s dicuss what union and union all does\n* `UNION` does a union without duplicates\n* `UNION ALL` takes into account duplicates as well.\n\n**Approach1**: So basically if you do a union all of employeeid on two tables the count will be 1 for employee id which are only present in one table.\nOnce we do a union all we can do a count(empid) using groupby (empid) and then check if count of(empid) = 1 /*note that we need to use having with aggregate function here*/\n\n\n**Approach2** : Basically we firstly check from table 1 which entries are not present in table2 using not in clause and similarly we check from table 1 which entries are not present in table2 and then do a union of these two.\n\nPersonally I feel approach one is better because if you were to do it for 3 tables then you can simply change your having condition.\n\n```\n\n/*SOLUTION 1*/\n\nSELECT T.employee_id from\n(\n SELECT * FROM Employees \n UNION ALL\n SELECT * FROM Salaries\n) T\n\nGROUP BY T.EMPLOYEE_ID\nHAVING COUNT(T.EMPLOYEE_ID) = 1 /*can also use count(*) */\nORDER BY T.EMPLOYEE_ID ASC\n\n\n/*\nSOLUTION 2\n*/\n\nSELECT E.employee_id as employee_id from Employees E\nWHERE E.employee_id NOT IN \n(\n SELECT employee_id from Salaries\n)\n\nUNION\n\nSELECT S.employee_id as employee_id from Salaries S\nWHERE S.employee_id NOT IN\n(\n SELECT employee_id from Employees\n)\n\nORDER BY employee_id ASC\n\n```\n\nPS: Please upvote if you find this useful. It would motivate me to write more detailed solutions. | 4 | 0 | [] | 2 |
employees-with-missing-information | SQL SERVER CASE WHEN + FULL OUTER JOIN | sql-server-case-when-full-outer-join-by-2pm3z | \nSELECT CASE WHEN name IS NULL THEN s.employee_id\n WHEN salary IS NULL THEN e.employee_id\n END as employee_id\nFROM Employees e\nFULL O | yiz670 | NORMAL | 2021-08-08T18:03:56.714340+00:00 | 2021-08-08T18:03:56.714380+00:00 | 1,328 | false | ```\nSELECT CASE WHEN name IS NULL THEN s.employee_id\n WHEN salary IS NULL THEN e.employee_id\n END as employee_id\nFROM Employees e\nFULL OUTER JOIN Salaries s\nON e.employee_id = s.employee_id\nWHERE name IS NULL or salary IS NULL -- get the ones without proper information\nORDER BY employee_id\n``` | 4 | 0 | [] | 3 |
employees-with-missing-information | Solution on PostgreSQL | solution-on-postgresql-by-itachi1999-5r2e | \n# Approach: using FULL JOIN\n\n\n# Code\nPostgreSQL []\nSELECT employee_id\nFROM Employees FULL JOIN Salaries USING(employee_id)\nWHERE name IS NULL OR salary | Itachi1999 | NORMAL | 2024-11-19T09:25:20.364947+00:00 | 2024-11-19T09:26:14.803404+00:00 | 140 | false | \n# Approach: using FULL JOIN\n\n\n# Code\n```PostgreSQL []\nSELECT employee_id\nFROM Employees FULL JOIN Salaries USING(employee_id)\nWHERE name IS NULL OR salary IS NULL;\n```\nIf you liked the solution, like it \uD83D\uDD3C | 3 | 0 | ['Database', 'PostgreSQL'] | 0 |
employees-with-missing-information | SQL SERVER : FULL JOIN - UNION approaching | sql-server-full-join-union-approaching-b-u1k2 | YOUR UPVOTE MAKE MY DAY <3\n\n\n# FULL JOIN\n\n/* Write your T-SQL query statement below */\nselect (\n case when e.name is null then s.employee_id\n | lshigami | NORMAL | 2024-04-03T11:57:49.236725+00:00 | 2024-04-03T11:57:49.236754+00:00 | 343 | false | # YOUR UPVOTE MAKE MY DAY <3\n\n\n# FULL JOIN\n```\n/* Write your T-SQL query statement below */\nselect (\n case when e.name is null then s.employee_id\n when s.salary is null then e.employee_id \n end\n ) as employee_id \nfrom employees e\nfull join salaries s\non s.employee_id=e.employee_id\nwhere name is null or salary is null\norder by case when e.name is null then s.employee_id\n when s.salary is null then e.employee_id \n end\n```\n# UNION\n```\nselect employee_id from employees where employee_id NOT IN\n(select employee_id from salaries)\nUNION\nselect employee_id from salaries where employee_id NOT IN\n(select employee_id from Employees )\norder by employee_id\n``` | 3 | 0 | ['MS SQL Server'] | 2 |
employees-with-missing-information | Pandas | SQL | Easy | Employees With Missing Information | pandas-sql-easy-employees-with-missing-i-f90m | see the Successfully Accepted Submission\n\n\nimport pandas as pd\n\ndef find_employees(employees: pd.DataFrame, salaries: pd.DataFrame) -> pd.DataFrame:\n # | Khosiyat | NORMAL | 2023-09-22T16:00:26.418929+00:00 | 2023-10-01T17:46:50.683899+00:00 | 199 | false | [see the Successfully Accepted Submission](https://leetcode.com/submissions/detail/1056242323/)\n\n```\nimport pandas as pd\n\ndef find_employees(employees: pd.DataFrame, salaries: pd.DataFrame) -> pd.DataFrame:\n # First, we must get unique employee IDs from both DataFrames, so first we concatenate two Series, one containing employee IDs from the `employees` DataFrame and the other containing employee IDs from the `salaries` DataFrame. After that, we can obtain the unique values from the combined Series.\n all_employee_ids = pd.concat([employees[\'employee_id\'], salaries[\'employee_id\']]).unique()\n\n # Then, we must find employee IDs that are in one DataFrame but not in the other\n missing_employee_ids = [emp_id for emp_id in all_employee_ids if emp_id not in employees[\'employee_id\'].values or emp_id not in salaries[\'employee_id\'].values]\n\n # After that, we create a DataFrame with the missing employee IDs\n employee_df = pd.DataFrame({\'employee_id\': missing_employee_ids})\n\n # In the next step, we sort the result by \'employee_id\'\n sorted_employee = employee_df.sort_values(by=\'employee_id\')\n\n # Finally, we reset the index\n structured_employee = sorted_employee.reset_index(drop=True)\n\n return structured_employee\n```\n\n**SQL**\n\n[see the Successfully Accepted Submission](https://leetcode.com/submissions/detail/1061744922/)\n\n```\nSELECT employee_id \nFROM Employees \nWHERE employee_id not in (SELECT employee_id FROM Salaries)\n\nUNION\n\nSELECT employee_id \nFROM Salaries \nWHERE employee_id not in (SELECT employee_id FROM Employees) \n\nORDER BY employee_id;\n```\n\n```\n-- Select \'employee_id\' values that are not present in the \'Salaries\' table\n-- by using a subquery with a NOT IN clause\nSELECT employee_id \nFROM Employees \nWHERE employee_id not in (SELECT employee_id FROM Salaries)\n\n-- Combine the results with the following query using UNION\nUNION\n\n-- Select \'employee_id\' values that are not present in the \'Employees\' table\n-- by using a subquery with a NOT IN clause\nSELECT employee_id \nFROM Salaries \nWHERE employee_id not in (SELECT employee_id FROM Employees)\n\n-- Order the combined results by \'employee_id\' in ascending order\nORDER BY employee_id;\n```\n\n\n\n# Pandas & SQL | SOLVED & EXPLAINED LIST\n\n**EASY**\n\n- [Combine Two Tables](https://leetcode.com/problems/combine-two-tables/solutions/4051076/pandas-sql-easy-combine-two-tables/)\n\n- [Employees Earning More Than Their Managers](https://leetcode.com/problems/employees-earning-more-than-their-managers/solutions/4051991/pandas-sql-easy-employees-earning-more-than-their-managers/)\n\n- [Duplicate Emails](https://leetcode.com/problems/duplicate-emails/solutions/4055225/pandas-easy-duplicate-emails/)\n\n- [Customers Who Never Order](https://leetcode.com/problems/customers-who-never-order/solutions/4055429/pandas-sql-easy-customers-who-never-order-easy-explained/)\n\n- [Delete Duplicate Emails](https://leetcode.com/problems/delete-duplicate-emails/solutions/4055572/pandas-sql-easy-delete-duplicate-emails-easy/)\n- [Rising Temperature](https://leetcode.com/problems/rising-temperature/solutions/4056328/pandas-sql-easy-rising-temperature-easy/)\n\n- [ Game Play Analysis I](https://leetcode.com/problems/game-play-analysis-i/solutions/4056422/pandas-sql-easy-game-play-analysis-i-easy/)\n\n- [Find Customer Referee](https://leetcode.com/problems/find-customer-referee/solutions/4056516/pandas-sql-easy-find-customer-referee-easy/)\n\n- [Classes More Than 5 Students](https://leetcode.com/problems/classes-more-than-5-students/solutions/4058381/pandas-sql-easy-classes-more-than-5-students-easy/)\n- [Employee Bonus](https://leetcode.com/problems/employee-bonus/solutions/4058430/pandas-sql-easy-employee-bonus/)\n\n- [Sales Person](https://leetcode.com/problems/sales-person/solutions/4058824/pandas-sql-easy-sales-person/)\n\n- [Biggest Single Number](https://leetcode.com/problems/biggest-single-number/solutions/4063950/pandas-sql-easy-biggest-single-number/)\n\n- [Not Boring Movies](https://leetcode.com/problems/not-boring-movies/solutions/4065350/pandas-sql-easy-not-boring-movies/)\n- [Swap Salary](https://leetcode.com/problems/swap-salary/solutions/4065423/pandas-sql-easy-swap-salary/)\n\n- [Actors & Directors Cooperated min Three Times](https://leetcode.com/problems/actors-and-directors-who-cooperated-at-least-three-times/solutions/4065511/pandas-sql-easy-explained-step-by-step-actors-directors-cooperated-min-three-times/)\n\n- [Product Sales Analysis I](https://leetcode.com/problems/product-sales-analysis-i/solutions/4065545/pandas-sql-easy-product-sales-analysis-i/)\n\n- [Project Employees I](https://leetcode.com/problems/project-employees-i/solutions/4065635/pandas-sql-easy-project-employees-i/)\n- [Sales Analysis III](https://leetcode.com/problems/sales-analysis-iii/solutions/4065755/sales-analysis-iii-pandas-easy/)\n\n- [Reformat Department Table](https://leetcode.com/problems/reformat-department-table/solutions/4066153/pandas-sql-easy-explained-step-by-step-reformat-department-table/)\n\n- [Top Travellers](https://leetcode.com/problems/top-travellers/solutions/4066252/top-travellers-pandas-easy-eaxplained-step-by-step/)\n\n- [Replace Employee ID With The Unique Identifier](https://leetcode.com/problems/replace-employee-id-with-the-unique-identifier/solutions/4066321/pandas-sql-easy-replace-employee-id-with-the-unique-identifier/)\n- [Group Sold Products By The Date](https://leetcode.com/problems/group-sold-products-by-the-date/solutions/4066344/pandas-sql-easy-explained-step-by-step-group-sold-products-by-the-date/)\n\n- [Customer Placing the Largest Number of Orders](https://leetcode.com/problems/customer-placing-the-largest-number-of-orders/solutions/4068822/pandas-sql-easy-explained-step-by-step-customer-placing-the-largest-number-of-orders/)\n\n- [Article Views I](https://leetcode.com/problems/article-views-i/solutions/4069777/pandas-sql-easy-article-views-i/)\n\n- [User Activity for the Past 30 Days I](https://leetcode.com/problems/user-activity-for-the-past-30-days-i/solutions/4069797/pandas-sql-easy-user-activity-for-the-past-30-days-i/)\n\n- [Find Users With Valid E-Mails](https://leetcode.com/problems/find-users-with-valid-e-mails/solutions/4069810/pandas-sql-easy-find-users-with-valid-e-mails/)\n\n- [Patients With a Condition](https://leetcode.com/problems/patients-with-a-condition/solutions/4069817/pandas-sql-easy-patients-with-a-condition/)\n\n- [Customer Who Visited but Did Not Make Any Transactions](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions/solutions/4072542/pandas-sql-easy-customer-who-visited-but-did-not-make-any-transactions/)\n\n\n- [Bank Account Summary II](https://leetcode.com/problems/bank-account-summary-ii/solutions/4072569/pandas-sql-easy-bank-account-summary-ii/)\n\n- [Invalid Tweets](https://leetcode.com/problems/invalid-tweets/solutions/4072599/pandas-sql-easy-invalid-tweets/)\n\n- [Daily Leads and Partners](https://leetcode.com/problems/daily-leads-and-partners/solutions/4072981/pandas-sql-easy-daily-leads-and-partners/)\n\n- [Recyclable and Low Fat Products](https://leetcode.com/problems/recyclable-and-low-fat-products/solutions/4073003/pandas-sql-easy-recyclable-and-low-fat-products/)\n\n- [Rearrange Products Table](https://leetcode.com/problems/rearrange-products-table/solutions/4073028/pandas-sql-easy-rearrange-products-table/)\n- [Calculate Special Bonus](https://leetcode.com/problems/calculate-special-bonus/solutions/4073595/pandas-sql-easy-calculate-special-bonus/)\n\n- [Count Unique Subjects](https://leetcode.com/problems/number-of-unique-subjects-taught-by-each-teacher/solutions/4073666/pandas-sql-easy-count-unique-subjects/)\n\n- [Count Unique Subjects](https://leetcode.com/problems/number-of-unique-subjects-taught-by-each-teacher/solutions/4073666/pandas-sql-easy-count-unique-subjects/)\n\n- [Fix Names in a Table](https://leetcode.com/problems/fix-names-in-a-table/solutions/4073695/pandas-sql-easy-fix-names-in-a-table/)\n- [Primary Department for Each Employee](https://leetcode.com/problems/primary-department-for-each-employee/solutions/4076183/pandas-sql-easy-primary-department-for-each-employee/)\n\n- [The Latest Login in 2020](https://leetcode.com/problems/the-latest-login-in-2020/solutions/4076240/pandas-sql-easy-the-latest-login-in-2020/)\n\n- [Find Total Time Spent by Each Employee](https://leetcode.com/problems/find-total-time-spent-by-each-employee/solutions/4076313/pandas-sql-easy-find-total-time-spent-by-each-employee/)\n\n- [Find Followers Count](https://leetcode.com/problems/find-followers-count/solutions/4076342/pandas-sql-easy-find-followers-count/)\n- [Percentage of Users Attended a Contest](https://leetcode.com/problems/percentage-of-users-attended-a-contest/solutions/4077301/pandas-sql-easy-percentage-of-users-attended-a-contest/)\n\n- [Employees With Missing Information](https://leetcode.com/problems/employees-with-missing-information/solutions/4077308/pandas-sql-easy-employees-with-missing-information/)\n\n- [Average Time of Process per Machine](https://leetcode.com/problems/average-time-of-process-per-machine/solutions/4077402/pandas-sql-easy-average-time-of-process-per-machine/)\n | 3 | 0 | ['MySQL'] | 0 |
employees-with-missing-information | MySQL Solution for Employees with Missing Information Problem | mysql-solution-for-employees-with-missin-wlrc | Intuition\r\n Describe your first thoughts on how to solve this problem. \r\nThe goal is to find the employee IDs for which either the name or the salary inform | Aman_Raj_Sinha | NORMAL | 2023-07-20T02:55:56.522910+00:00 | 2023-07-20T02:55:56.522941+00:00 | 869 | false | # Intuition\r\n<!-- Describe your first thoughts on how to solve this problem. -->\r\nThe goal is to find the employee IDs for which either the name or the salary information is missing. We can achieve this by performing a combination of LEFT JOIN and RIGHT JOIN between the Employees and Salaries tables and then filtering the rows where the name or salary is NULL.\r\n\r\n# Approach\r\n<!-- Describe your approach to solving the problem. -->\r\n1. Perform a LEFT JOIN between the Employees and Salaries tables to get all rows from the Employees table and matching rows from the Salaries table based on the employee_id.\r\n1. In the WHERE clause, filter the rows where the name from the Employees table is NULL or the salary from the Salaries table is NULL. This will give us the employee IDs for which either the name or salary information is missing.\r\n1. Perform a RIGHT JOIN between the Employees and Salaries tables to get all rows from the Salaries table and matching rows from the Employees table based on the employee_id.\r\n1. In the WHERE clause, filter the rows where the name from the Employees table is NULL or the salary from the Salaries table is NULL. This will give us additional employee IDs for which either the name or salary information is missing.\r\n1. Use the UNION operator to combine the results of both joins to get the final set of employee IDs with missing information.\r\n1. Sort the employee IDs in ascending order using ORDER BY.\r\n\r\n# Complexity\r\n- Time complexity:\r\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\r\nThe time complexity of the SQL query is O(n + m), where n is the number of rows in the Employees table and m is the number of rows in the Salaries table. This is because we need to perform two joins, one for each table, and then filter the rows based on the WHERE clause.\r\n\r\n- Space complexity:\r\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\r\nThe space complexity is O(max(n, m)), where n is the number of rows in the Employees table and m is the number of rows in the Salaries table. This is because the space required to store the results of the two joins and the UNION operation depends on the maximum number of rows between the two tables.\r\n\r\n# Code\r\n```\r\n# Write your MySQL query statement below\r\nSELECT COALESCE(e.employee_id, s.employee_id) AS employee_id\r\nFROM Employees e\r\nLEFT JOIN Salaries s ON e.employee_id = s.employee_id\r\nWHERE e.name IS NULL OR s.salary IS NULL\r\n\r\nUNION\r\n\r\nSELECT COALESCE(e.employee_id, s.employee_id) AS employee_id\r\nFROM Employees e\r\nRIGHT JOIN Salaries s ON e.employee_id = s.employee_id\r\nWHERE e.name IS NULL OR s.salary IS NULL\r\n\r\nORDER BY employee_id;\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n``` | 3 | 0 | ['MySQL'] | 1 |
employees-with-missing-information | using UNION | using-union-by-priyanka_0499-y9my | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | Priyanka_0499 | NORMAL | 2023-03-25T12:26:12.402135+00:00 | 2023-03-25T12:26:12.402181+00:00 | 1,653 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/* Write your T-SQL query statement below */\nselect employee_id \nfrom Employees\nwhere employee_id\nnot in(select employee_id from salaries)\nunion\nselect employee_id \nfrom salaries\nwhere employee_id\nnot in(select employee_id from Employees)\n``` | 3 | 0 | ['MS SQL Server'] | 1 |
employees-with-missing-information | MySQL Solution | mysql-solution-by-pranto1209-1oyh | Code\n\n# Write your MySQL query statement below\nselect Employees.employee_id from Employees natural left join Salaries \nwhere Salaries.salary is null\nunion | pranto1209 | NORMAL | 2023-03-08T11:31:48.293830+00:00 | 2023-03-08T11:31:48.293859+00:00 | 1,951 | false | # Code\n```\n# Write your MySQL query statement below\nselect Employees.employee_id from Employees natural left join Salaries \nwhere Salaries.salary is null\nunion \nselect Salaries.employee_id from salaries natural left join Employees \nwhere Employees.name is null\norder by employee_id;\n``` | 3 | 0 | ['MySQL'] | 0 |
employees-with-missing-information | MySql & Oracle sql solution || UNION || NOT IN | mysql-oracle-sql-solution-union-not-in-b-w2sg | MySQL/Oracle sql solution\n\nSELECT employee_id\nFROM Employees\nWHERE employee_id NOT IN (SELECT employee_id\n FROM Salaries)\nUNION\n | Troz95 | NORMAL | 2022-11-18T15:39:12.785980+00:00 | 2022-12-06T21:15:20.463198+00:00 | 508 | false | MySQL/Oracle sql solution\n```\nSELECT employee_id\nFROM Employees\nWHERE employee_id NOT IN (SELECT employee_id\n FROM Salaries)\nUNION\nSELECT employee_id\nFROM Salaries\nWHERE employee_id NOT IN (SELECT employee_id\n FROM Employees)\nORDER BY employee_id;\n``` | 3 | 0 | ['MySQL', 'Oracle'] | 0 |
employees-with-missing-information | Easy and Simple | easy-and-simple-by-bipinthakur-l75l | ```\n# Write your MySQL query statement below\nselect employee_id from Employees where employee_id not in (select employee_id from salaries)\nunion \nselect emp | BipinThakur | NORMAL | 2022-09-18T10:53:23.144083+00:00 | 2022-09-18T10:53:23.144162+00:00 | 1,193 | false | ```\n# Write your MySQL query statement below\nselect employee_id from Employees where employee_id not in (select employee_id from salaries)\nunion \nselect employee_id from salaries where employee_id not in(select employee_id from employees)\norder by employee_id | 3 | 0 | ['Union Find', 'MySQL'] | 0 |
employees-with-missing-information | Solution Here (MySQL WILL NOT SUPPORT FULL JOIN) | solution-here-mysql-will-not-support-ful-4csb | \nSELECT employee_id \nFROM Employees \nWHERE employee_id NOT IN (SELECT employee_id FROM Salaries)\nUNION\nSELECT employee_id\nFROM Salaries \nWHERE employee_i | Prabal_Nair | NORMAL | 2022-09-04T10:42:03.360283+00:00 | 2022-09-04T10:42:03.360328+00:00 | 284 | false | ```\nSELECT employee_id \nFROM Employees \nWHERE employee_id NOT IN (SELECT employee_id FROM Salaries)\nUNION\nSELECT employee_id\nFROM Salaries \nWHERE employee_id NOT IN (SELECT employee_id FROM Employees)\n\nORDER BY employee_id\n\n\n``` | 3 | 0 | [] | 0 |
employees-with-missing-information | Beginner Level Solution With Sub-query and Union | beginner-level-solution-with-sub-query-a-r6yc | Please upvote if you find it helpful. Thank you :)\n\nSolution:\n\nSELECT employee_id\nFROM Employees\nWHERE employee_id NOT IN (SELECT employee_id FROM Salarie | utsav_akash | NORMAL | 2022-08-20T07:39:02.423883+00:00 | 2022-08-20T07:39:02.423927+00:00 | 244 | false | Please **upvote** if you find it helpful. Thank you :)\n\n**Solution:**\n```\nSELECT employee_id\nFROM Employees\nWHERE employee_id NOT IN (SELECT employee_id FROM Salaries)\nUNION\nSELECT employee_id\nFROM Salaries\nWHERE employee_id NOT IN (SELECT employee_id FROM Employees)\nORDER BY employee_id;\n``` | 3 | 0 | ['Union Find', 'MySQL'] | 0 |
employees-with-missing-information | MS SQL | SIMPLE | 2 APPROACH | ms-sql-simple-2-approach-by-lavinamall-j5jf | Using UNION ALL\n\nSELECT employee_id\nFROM (\n SELECT E.employee_id\n FROM Employees E\n LEFT JOIN Salaries S ON S.employee_id = E.employe | lavinamall | NORMAL | 2022-07-16T17:51:32.550877+00:00 | 2022-07-16T18:00:14.655683+00:00 | 621 | false | 1. Using **UNION ALL**\n```\nSELECT employee_id\nFROM (\n SELECT E.employee_id\n FROM Employees E\n LEFT JOIN Salaries S ON S.employee_id = E.employee_id\n WHERE name IS NULL OR salary IS NULL\n\n UNION ALL\n\n SELECT S.employee_id\n FROM Employees E\n RIGHT JOIN Salaries S ON S.employee_id = E.employee_id\n WHERE name IS NULL OR salary IS NULL\n)A\nORDER BY 1 \n```\n\n2. Using **FULL OUTER JOIN** \n```\nSELECT ISNULL(E.employee_id, S.employee_id) employee_id\nFROM Employees E\nFULL OUTER JOIN Salaries S ON S.employee_id = E.employee_id\nWHERE E.employee_id IS NULL OR S.employee_id IS NULL\nORDER BY 1 ASC\n``` | 3 | 0 | ['Union Find', 'MS SQL Server'] | 1 |
employees-with-missing-information | ✅ MySql | mysql-by-ranbeer_singh-j20p | Using UNION\n\nSELECT employee_id\nFROM\n( SELECT employee_id FROM Employees\nUNION ALL \nSELECT employee_id FROM Salaries\n)emp\nGROUP BY employee_id\nHAVING C | Ranbeer_Singh | NORMAL | 2022-07-10T13:05:43.295100+00:00 | 2022-07-10T13:05:43.295151+00:00 | 275 | false | Using **UNION**\n```\nSELECT employee_id\nFROM\n( SELECT employee_id FROM Employees\nUNION ALL \nSELECT employee_id FROM Salaries\n)emp\nGROUP BY employee_id\nHAVING COUNT(employee_id)=1\nORDER BY 1;\n``` | 3 | 0 | ['Union Find', 'MySQL'] | 1 |
employees-with-missing-information | A simple Solution in PostgreSQL | a-simple-solution-in-postgresql-by-toshp-ygjl | \nSELECT e.employee_id FROM Employees e \n\tLEFT JOIN salaries s ON e.employee_id = s.employee_id\n\t\tWHERE s.salary IS NULL\nUNION\nSELECT s.employee_id FROM | toshpolaty | NORMAL | 2022-07-05T16:20:32.907556+00:00 | 2022-07-05T16:20:32.907600+00:00 | 105 | false | ```\nSELECT e.employee_id FROM Employees e \n\tLEFT JOIN salaries s ON e.employee_id = s.employee_id\n\t\tWHERE s.salary IS NULL\nUNION\nSELECT s.employee_id FROM Salaries s \n\tLEFT JOIN employees e ON e.employee_id = s.employee_id\n\t\tWHERE e.name IS NULL;\n``` | 3 | 0 | ['Union Find'] | 0 |
employees-with-missing-information | [MySQL] Union Table Solution | Easy Solution | | mysql-union-table-solution-easy-solution-enhb | \nSELECT emp.employee_id\nFROM\n (SELECT \n salaries.employee_id\n FROM\n employees RIGHT JOIN salaries\n ON employees.employee_id = | yash_vish87 | NORMAL | 2022-07-03T12:50:58.407632+00:00 | 2022-07-03T12:50:58.407677+00:00 | 312 | false | ```\nSELECT emp.employee_id\nFROM\n (SELECT \n salaries.employee_id\n FROM\n employees RIGHT JOIN salaries\n ON employees.employee_id = salaries.employee_id\n WHERE\n employees.name IS NULL\n\n UNION\n\n SELECT \n employees.employee_id\n FROM\n employees LEFT JOIN salaries\n ON employees.employee_id = salaries.employee_id\n WHERE\n salaries.salary IS NULL\n ) AS emp\nORDER BY emp.employee_id\n``` | 3 | 0 | ['Union Find', 'MySQL'] | 0 |
employees-with-missing-information | easy approach mysql | easy-approach-mysql-by-kakashi2112-66lp | SELECT employee_id FROM Employees \nWHERE employee_id NOT IN (SELECT employee_id FROM Salaries)\nUNION\nSELECT employee_id FROM Salaries \nWHERE employee_id NOT | kakashi2112 | NORMAL | 2022-07-01T10:01:04.496596+00:00 | 2022-07-01T10:01:04.496641+00:00 | 290 | false | SELECT employee_id FROM Employees \nWHERE employee_id NOT IN (SELECT employee_id FROM Salaries)\nUNION\nSELECT employee_id FROM Salaries \nWHERE employee_id NOT IN (SELECT employee_id FROM Employees)\nORDER BY employee_id; | 3 | 0 | ['MySQL'] | 0 |
employees-with-missing-information | SQL | Easy | Using SELECT & UNION | sql-easy-using-select-union-by-nidhi_ran-ej5l | \nSELECT employee_id FROM Employees \n\tWHERE employee_id NOT IN (SELECT employee_id FROM Salaries)\nUNION\nSELECT employee_id FROM Salaries \n\tWHERE employee_ | nidhi_ranjan | NORMAL | 2022-06-29T03:44:08.862510+00:00 | 2022-06-29T03:44:08.862562+00:00 | 196 | false | ```\nSELECT employee_id FROM Employees \n\tWHERE employee_id NOT IN (SELECT employee_id FROM Salaries)\nUNION\nSELECT employee_id FROM Salaries \n\tWHERE employee_id NOT IN (SELECT employee_id FROM Employees)\nORDER BY employee_id;\n```\nPlease upvote if you found this useful :) | 3 | 0 | ['Union Find', 'MySQL'] | 1 |
employees-with-missing-information | Simple approach w/o using Union | simple-approach-wo-using-union-by-shruti-nj3j | \nSELECT COALESCE(E.EMPLOYEE_ID,S.EMPLOYEE_ID) AS EMPLOYEE_ID\nFROM EMPLOYEES E\nFULL OUTER JOIN SALARIES S ON E.EMPLOYEE_ID=S.EMPLOYEE_ID\nWHERE E.NAME IS NULL | ShrutiGuptaAllenki | NORMAL | 2022-06-24T06:04:43.570939+00:00 | 2022-06-24T06:04:43.570989+00:00 | 510 | false | ```\nSELECT COALESCE(E.EMPLOYEE_ID,S.EMPLOYEE_ID) AS EMPLOYEE_ID\nFROM EMPLOYEES E\nFULL OUTER JOIN SALARIES S ON E.EMPLOYEE_ID=S.EMPLOYEE_ID\nWHERE E.NAME IS NULL OR S.SALARY IS NULL\nORDER BY COALESCE(E.EMPLOYEE_ID,S.EMPLOYEE_ID)\n``` | 3 | 0 | ['MS SQL Server'] | 1 |
employees-with-missing-information | mysql | easy | using union | mysql-easy-using-union-by-ahirwarsandeep-ocvk | \nselect employee_id \nfrom Salaries\nwhere employee_id not in (select employee_id from Employees)\nunion\nselect employee_id \nfrom Employees\nwhere employee_i | ahirwarsandeepindia | NORMAL | 2022-06-18T04:58:46.272810+00:00 | 2022-06-18T04:58:46.272861+00:00 | 207 | false | ```\nselect employee_id \nfrom Salaries\nwhere employee_id not in (select employee_id from Employees)\nunion\nselect employee_id \nfrom Employees\nwhere employee_id not in (select employee_id from Salaries)\norder by employee_id\n``` | 3 | 0 | ['Union Find', 'MySQL'] | 0 |
employees-with-missing-information | Full Outer Join easy | full-outer-join-easy-by-derksl2022-b69p | ```\nselect\nisnull(e.employee_id, s.employee_id) as employee_id\nfrom\nemployees e full outer join salaries s on e.employee_id=s.employee_id\nwhere e.name IS N | derksl2022 | NORMAL | 2022-06-14T02:07:53.874469+00:00 | 2022-06-14T02:07:53.874498+00:00 | 879 | false | ```\nselect\nisnull(e.employee_id, s.employee_id) as employee_id\nfrom\nemployees e full outer join salaries s on e.employee_id=s.employee_id\nwhere e.name IS NULL or s.salary is null\norder by isnull(e.employee_id, s.employee_id) asc | 3 | 0 | ['MS SQL Server'] | 1 |
employees-with-missing-information | TSQL Full outer join statement | tsql-full-outer-join-statement-by-yulinc-sc3t | \nSELECT ISNULL(A.employee_id,B.employee_id) AS employee_id\nFROM Employees A\nFULL OUTER JOIN Salaries B\nON A.employee_id = B.employee_id\nWHERE A.name IS NUL | yulinchao | NORMAL | 2022-05-13T07:56:37.886690+00:00 | 2022-05-13T07:56:37.886726+00:00 | 250 | false | ```\nSELECT ISNULL(A.employee_id,B.employee_id) AS employee_id\nFROM Employees A\nFULL OUTER JOIN Salaries B\nON A.employee_id = B.employee_id\nWHERE A.name IS NULL OR B.salary IS NULL\nORDER BY employee_id\n``` | 3 | 0 | [] | 1 |
employees-with-missing-information | MySQL Solution | mysql-solution-by-haoli1024-snjf | SELECT e.employee_id\nFROM Employees e\nWHERE e.employee_id NOT IN (SELECT s.employee_id FROM Salaries s)\n\nUNION\n\nSELECT s.employee_id\nFROM Salaries s\nWHE | haoli1024 | NORMAL | 2022-04-17T18:37:52.689421+00:00 | 2022-04-17T18:37:52.689532+00:00 | 306 | false | SELECT e.employee_id\nFROM Employees e\nWHERE e.employee_id NOT IN (SELECT s.employee_id FROM Salaries s)\n\nUNION\n\nSELECT s.employee_id\nFROM Salaries s\nWHERE s.employee_id NOT IN (SELECT e.employee_id FROM Employees e)\n\nORDER BY employee_id; | 3 | 0 | [] | 0 |
employees-with-missing-information | MySQL Full Join using UNION | mysql-full-join-using-union-by-sbd5_941-4o0i | The simple solution here would be to do full outer join and find the id\'s without salary or name\nUnfortunately, We don\'t have FULL OUTER JOIN in MySQL, to ac | sbd5_941 | NORMAL | 2022-04-10T15:05:07.921710+00:00 | 2022-04-10T15:05:07.921757+00:00 | 364 | false | The simple solution here would be to do full outer join and find the id\'s without salary or name\nUnfortunately, We don\'t have FULL OUTER JOIN in MySQL, to achieve that we can create it using UNION of left outer and right outer\n\n```\n# Write your MySQL query statement below\n\nSELECT res.employee_id FROM\n(\n SELECT *\n FROM employees\n LEFT OUTER JOIN salaries\n USING (employee_id)\n \n UNION\n \n SELECT *\n FROM employees\n RIGHT OUTER JOIN salaries\n USING (employee_id)\n) res\nWHERE name IS NULL \nOR salary IS NULL\nORDER BY employee_id;\n``` | 3 | 0 | ['Union Find', 'MySQL'] | 1 |
employees-with-missing-information | [MySQL] UNION | mysql-union-by-ye15-e6zx | \n\nSELECT employee_id FROM Employees WHERE employee_id NOT IN (SELECT employee_id FROM Salaries)\nUNION \nSELECT employee_id FROM Salaries WHERE employee_id NO | ye15 | NORMAL | 2021-08-11T22:21:28.499268+00:00 | 2021-08-11T22:21:28.499308+00:00 | 497 | false | \n```\nSELECT employee_id FROM Employees WHERE employee_id NOT IN (SELECT employee_id FROM Salaries)\nUNION \nSELECT employee_id FROM Salaries WHERE employee_id NOT IN (SELECT employee_id FROM Employees)\nORDER BY 1\n``` | 3 | 0 | ['MySQL'] | 0 |
employees-with-missing-information | Simplest solution using NOT IN & UNION in Postgres 🔥 | simplest-solution-using-not-in-union-in-fa3l8 | Code | AmoghaMayya | NORMAL | 2025-01-22T16:51:43.088636+00:00 | 2025-01-22T16:51:43.088636+00:00 | 178 | false |
# Code
```postgresql []
-- Write your PostgreSQL query statement below
select employee_id from employees where employee_id not in (select employee_id from salaries)
union
select employee_id from salaries where employee_id not in (select employee_id from
employees)
order by employee_id asc;
``` | 2 | 0 | ['PostgreSQL'] | 0 |
employees-with-missing-information | ☑️ Finding Employees With Missing Information ☑️ | finding-employees-with-missing-informati-30gm | Code | Abdusalom_16 | NORMAL | 2024-12-28T05:01:03.744331+00:00 | 2024-12-28T05:01:03.744331+00:00 | 168 | false | # Code
```postgresql []
select coalesce(e.employee_id, s.employee_id) employee_id from employees e
full join Salaries s
on e.employee_id = s.employee_id
where salary is null or name is null;
``` | 2 | 0 | ['Database', 'MySQL', 'PostgreSQL'] | 0 |
employees-with-missing-information | Beginner-Friendly Solution Using MySQL || Beats 92% Users || Clear | beginner-friendly-solution-using-mysql-b-3ytm | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | truongtamthanh2004 | NORMAL | 2024-08-23T11:13:10.413209+00:00 | 2024-08-23T11:13:10.413249+00:00 | 883 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```mysql []\n# Write your MySQL query statement below\nselect e.employee_id \nfrom Employees e\nleft join Salaries s on e.employee_id = s.employee_id\nwhere salary is null\nunion\nselect s.employee_id \nfrom Employees e\nright join Salaries s on e.employee_id = s.employee_id\nwhere name is null\norder by employee_id\n``` | 2 | 0 | ['MySQL'] | 0 |
employees-with-missing-information | Super Easy solution. | super-easy-solution-by-lovepreet12a-qp84 | Intuition\n\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Tim | Lovepreet12a | NORMAL | 2023-08-14T18:50:22.600166+00:00 | 2023-08-14T18:50:22.600187+00:00 | 60 | false | # Intuition\n\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/* Write your T-SQL query statement below */\n\nSELECT COALESCE(E.employee_id, S.employee_id) AS employee_id\nFROM Employees E\nFULL JOIN Salaries S ON E.employee_id = S.employee_id\nWHERE E.employee_id IS NULL OR S.employee_id IS NULL\nORDER BY employee_id;\n\n\n``` | 2 | 0 | ['MS SQL Server'] | 1 |
employees-with-missing-information | Full outer join emulation in MySQL + Alternate Quick and Intuitive Approach | full-outer-join-emulation-in-mysql-alter-xcod | Code\n\n# Write your MySQL query statement below\n# Emulating full outer join in SQL\nSELECT EMPLOYEE_ID FROM\n(SELECT E.EMPLOYEE_ID, NAME, SALARY FROM EMPLOYEE | sonalibasu24 | NORMAL | 2023-01-22T16:28:38.631293+00:00 | 2023-01-22T16:28:38.631340+00:00 | 24 | false | # Code\n```\n# Write your MySQL query statement below\n# Emulating full outer join in SQL\nSELECT EMPLOYEE_ID FROM\n(SELECT E.EMPLOYEE_ID, NAME, SALARY FROM EMPLOYEES E\nLEFT OUTER JOIN SALARIES S ON E.EMPLOYEE_ID = S.EMPLOYEE_ID\nUNION \nSELECT S.EMPLOYEE_ID, NAME, SALARY FROM EMPLOYEES E\nRIGHT OUTER JOIN SALARIES S ON E.EMPLOYEE_ID = S.EMPLOYEE_ID) T\nWHERE NAME IS NULL OR SALARY IS NULL\nORDER BY employee_id\n\n# Alternate: Intuitive \nSELECT EMPLOYEE_ID FROM EMPLOYEES WHERE EMPLOYEE_ID NOT IN (SELECT EMPLOYEE_ID FROM SALARIES)\nUNION\nSELECT EMPLOYEE_ID FROM SALARIES WHERE EMPLOYEE_ID NOT IN (SELECT EMPLOYEE_ID FROM EMPLOYEES)\nORDER BY 1 ASC \n``` | 2 | 0 | ['MySQL'] | 0 |
employees-with-missing-information | CTE solution | cte-solution-by-jackyl1996-9fmq | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | jackyl1996 | NORMAL | 2023-01-12T20:07:38.734307+00:00 | 2023-01-12T20:07:38.734351+00:00 | 73 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nWITH helper AS (\n SELECT * FROM Employees\n UNION SELECT * FROM Salaries\n)\nSELECT employee_id FROM helper\nGROUP BY employee_id \nHAVING COUNT(employee_id) < 2\nORDER BY employee_id ASC | 2 | 0 | ['MySQL'] | 0 |
employees-with-missing-information | Oracle Simple Solution beats 86% | oracle-simple-solution-beats-86-by-deepa-3fv6 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | deepak2332271 | NORMAL | 2023-01-07T18:03:59.802506+00:00 | 2023-01-07T18:03:59.802562+00:00 | 80 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/* Write your PL/SQL query statement below */\n\nselect coalesce(e.employee_id,s.employee_id) as employee_id \nfrom Employees e FULL OUTER JOIN Salaries s\nON e.employee_id = s.employee_id\nwhere name is null or salary is null\norder by employee_id;\n``` | 2 | 0 | ['Oracle'] | 0 |
employees-with-missing-information | Employees With Missing Information Solution MySql | employees-with-missing-information-solut-p3pm | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | bhupendra786 | NORMAL | 2023-01-01T11:07:09.519962+00:00 | 2023-01-01T11:07:09.520002+00:00 | 1,986 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n# Write your MySQL query statement below\nselect e.employee_id\n from Employees e\n left join Salaries s\n using(employee_id)\n where salary is null\nunion all\nselect s.employee_id\n from Employees e\n right join Salaries s\n using(employee_id)\n where name is null\norder by employee_id;\n``` | 2 | 0 | ['Database', 'MySQL'] | 0 |
employees-with-missing-information | Fast solution || using Not in and Union and Order by employee_id | fast-solution-using-not-in-and-union-and-r963 | \n\n# Code\n\n# Write your MySQL query statement below\n\nselect employee_id from salaries where employee_id not in \n(select employee_id from employees)\nunion | iamakhil | NORMAL | 2022-12-18T19:45:48.219782+00:00 | 2022-12-18T19:45:48.219854+00:00 | 909 | false | \n\n# Code\n```\n# Write your MySQL query statement below\n\nselect employee_id from salaries where employee_id not in \n(select employee_id from employees)\nunion\nselect employee_id from employees where employee_id not in \n(select employee_id from salaries)\norder by employee_id\n\n``` | 2 | 0 | ['MySQL'] | 1 |
employees-with-missing-information | Union on left joins | union-on-left-joins-by-mlacrosse3-y7z1 | Code\n\n/* Write your T-SQL query statement below */\n\nselect distinct c.employee_id from \n(\nselect e.employee_id, e.name, s2.salary from Employees e\nleft j | mlacrosse3 | NORMAL | 2022-12-14T01:10:17.662922+00:00 | 2022-12-14T01:10:17.663086+00:00 | 1,453 | false | # Code\n```\n/* Write your T-SQL query statement below */\n\nselect distinct c.employee_id from \n(\nselect e.employee_id, e.name, s2.salary from Employees e\nleft join Salaries s2 on s2.employee_id = e.employee_id\n\nunion\n\nselect s.employee_id, e2.name, s.salary from Salaries s\nleft join Employees e2 on e2.employee_id = s.employee_id\n) as c\nwhere c.name is null or c.salary is null\norder by c.employee_id\n``` | 2 | 0 | ['MS SQL Server'] | 0 |
employees-with-missing-information | mysql, left join / right join / union | mysql-left-join-right-join-union-by-nov0-96ep | There is no outer join in MySQL.\nhttps://leetcode.com/submissions/detail/857838266/\n\n# Write your MySQL query statement below\n(\n select e.employee_id \n | nov05 | NORMAL | 2022-12-11T01:14:55.065565+00:00 | 2022-12-11T01:14:55.065607+00:00 | 111 | false | There is no `outer join` in MySQL.\nhttps://leetcode.com/submissions/detail/857838266/\n```\n# Write your MySQL query statement below\n(\n select e.employee_id \n from Employees as e\n left join Salaries as s\n on e.employee_id = s.employee_id\n where s.employee_id is null\n)\nunion\n(\n select s.employee_id\n from Employees as e\n right join Salaries as s\n on e.employee_id = s.employee_id\n where e.employee_id is null\n)\norder by employee_id\n``` | 2 | 0 | ['Union Find', 'MySQL'] | 0 |
employees-with-missing-information | COME WATCH!! EASIEST MYSQL | BEGINNERS METHOD | MYSQL | come-watch-easiest-mysql-beginners-metho-170j | UNION IS THE KEY!!!\n\n# Code\n\n# Write your MySQL query statement below\nSelect employee_id from salaries where employee_id not in (Select employee_id from em | akakabarry | NORMAL | 2022-12-03T09:07:33.484698+00:00 | 2022-12-03T09:07:33.484724+00:00 | 231 | false | UNION IS THE KEY!!!\n\n# Code\n```\n# Write your MySQL query statement below\nSelect employee_id from salaries where employee_id not in (Select employee_id from employees)\nunion \nSelect employee_id from employees where employee_id not in (Select employee_id from salaries) order by employee_id\n``` | 2 | 0 | ['MySQL'] | 0 |
employees-with-missing-information | 3 MYSQL Solutions | 3-mysql-solutions-by-vikasmalviya98-jin6 | FASTEST : Using Group BY\nSELECT T.employee_id FROM\n(\n SELECT * FROM Employees \n UNION ALL\n SELECT * FROM Salaries\n) T\nGROUP BY T.employee_id\nHA | vikasmalviya98 | NORMAL | 2022-12-02T05:08:37.647258+00:00 | 2022-12-02T05:16:21.741135+00:00 | 1,379 | false | #FASTEST : Using Group BY\nSELECT T.employee_id FROM\n(\n SELECT * FROM Employees \n UNION ALL\n SELECT * FROM Salaries\n) T\nGROUP BY T.employee_id\nHAVING COUNT(T.employee_id) = 1 \nORDER BY T.employee_id ASC;\n\n#Using UNION and WHERE NOT IN\nSELECT employee_id FROM Salaries WHERE employee_id NOT IN (SELECT employee_id FROM Employees WHERE name IS NOT NULL)\nUNION\nSELECT employee_id FROM Employees WHERE employee_id NOT IN (SELECT employee_id FROM Salaries WHERE salary IS NOT NULL)\nORDER BY employee_id ASC;\n\n#Using JOIN\nSELECT JOINEDTABLE.employee_id\nFROM\n ( \n SELECT *\n FROM Employees\n LEFT JOIN Salaries\n USING(employee_id)\n UNION\n SELECT * \n FROM Salaries\n LEFT JOIN Employees\n USING(employee_id)\n )\n AS JOINEDTABLE\nWHERE JOINEDTABLE.salary IS NULL OR JOINEDTABLE.name IS NULL\nORDER BY JOINEDTABLE.employee_id ASC; | 2 | 0 | ['Union Find', 'MySQL'] | 0 |
employees-with-missing-information | All three solutions - last one is epic | all-three-solutions-last-one-is-epic-by-uurdq | Solution 1\n\nSELECT employee_id from Employees e WHERE employee_id not in (Select employee_id from Salaries)\nUNION \nSELECT employee_id from Salaries s WHERE | sandy_inspires | NORMAL | 2022-09-23T05:46:12.870374+00:00 | 2022-09-23T08:12:57.281335+00:00 | 186 | false | Solution 1\n```\nSELECT employee_id from Employees e WHERE employee_id not in (Select employee_id from Salaries)\nUNION \nSELECT employee_id from Salaries s WHERE employee_id not in (Select employee_id from Employees)\nORDER BY employee_id;\n```\n\n\nSolution 2\n```\nSelect e.employee_id from Employees e \nLEFT JOIN Salaries s \nON e.employee_id = s.employee_id\nWHERE s.salary is NULL\n\nUNION\n\nSelect s.employee_id from Salaries s\nLEFT JOIN Employees e \nON e.employee_id = s.employee_id\nWHERE e.name is NULL\n\nORDER BY employee_id;\n```\n\nSolution 3 (epic)\n```\nselect T.employee_id from\n\n(select * from Employees\nunion\nselect * from Salaries\n) as T\n\ngroup by T.employee_id\n\nhaving count(T.employee_id) < 2\n\norder by T.employee_id asc\n\n``` | 2 | 0 | ['MySQL'] | 1 |
employees-with-missing-information | Here is solution with left join and union | here-is-solution-with-left-join-and-unio-sqnb | sql\nSELECT e.employee_id \nFROM Employees e\nLEFT JOIN Salaries s ON e.employee_id = s.employee_id\nWHERE s.employee_id IS NULL\nUNION \nSELECT s.employee_id \ | trungmb007 | NORMAL | 2022-09-05T08:08:13.369381+00:00 | 2022-09-05T08:08:13.369417+00:00 | 186 | false | ```sql\nSELECT e.employee_id \nFROM Employees e\nLEFT JOIN Salaries s ON e.employee_id = s.employee_id\nWHERE s.employee_id IS NULL\nUNION \nSELECT s.employee_id \nFROM Salaries s\nLEFT JOIN Employees e ON e.employee_id = s.employee_id\nWHERE e.employee_id IS NULL\nORDER BY employee_id\n``` | 2 | 0 | [] | 0 |
employees-with-missing-information | Neat and Easy Solution | neat-and-easy-solution-by-pranayppatil-88vq | #Solution\n\n\nSELECT employee_id FROM Employees WHERE employee_id NOT IN (SELECT employee_id FROM Salaries)\nUNION \nSELECT employee_id FROM Salaries WHERE emp | PranayPPatil | NORMAL | 2022-09-04T05:37:12.191173+00:00 | 2022-09-04T05:37:12.191234+00:00 | 153 | false | **#Solution**\n\n\nSELECT employee_id FROM Employees WHERE employee_id NOT IN (SELECT employee_id FROM Salaries)\nUNION \nSELECT employee_id FROM Salaries WHERE employee_id NOT IN (SELECT employee_id FROM Employees)\n\nORDER BY 1 ASC; | 2 | 0 | ['Union Find', 'MySQL'] | 0 |
employees-with-missing-information | Fast NOT EXISTS + UNION Solution | fast-not-exists-union-solution-by-aleksa-kwt6 | \nSELECT employee_id FROM Employees e\nWHERE NOT EXISTS (SELECT employee_id FROM Salaries s WHERE e.employee_id = s.employee_id)\n\nUNION \n\nSELECT employee_id | AleksandrEfimenko | NORMAL | 2022-09-02T10:30:44.029537+00:00 | 2022-09-02T10:30:44.029577+00:00 | 132 | false | ```\nSELECT employee_id FROM Employees e\nWHERE NOT EXISTS (SELECT employee_id FROM Salaries s WHERE e.employee_id = s.employee_id)\n\nUNION \n\nSELECT employee_id FROM Salaries s\nWHERE NOT EXISTS (SELECT employee_id FROM Employees e WHERE e.employee_id = s.employee_id)\n\nORDER BY employee_id\n``` | 2 | 0 | ['Union Find'] | 0 |
employees-with-missing-information | Simple MySQL solution [UNION] | simple-mysql-solution-union-by-mohammedh-svoc | In this problem we are required to write an SQL query to report the IDs of all the employees with missing information. The information of an employee is missing | MohammedHamza | NORMAL | 2022-08-26T17:51:55.201154+00:00 | 2022-08-26T17:51:55.201195+00:00 | 144 | false | In this problem we are required to write **an SQL query to report the IDs of all the employees with missing information. The information of an employee is missing if:**\n\n**The employee\'s name is missing, or\nThe employee\'s salary is missing.**\n\nAnd we also are supposed to return the result table **return the result table ordered by employee_id in ascending order.**\n\nUsing the **NOT IN query before UNION** I have checked if the **name is misssing**\n\n```\nSELECT employee_id \nFROM Employees\nWHERE employee_id \nNOT IN (SELECT employee_id FROM Salaries)\n```\n\nUsing the **NOT IN query after UNION** I have checked if the **name is misssing**\n\n```\nSELECT employee_id \nFROM Salaries\nWHERE employee_id \nNOT IN (SELECT employee_id FROM Employees)\n```\n\nNow using **UNION** to merge both queries.\n```\nSELECT employee_id \nFROM Employees\nWHERE employee_id \nNOT IN (SELECT employee_id FROM Salaries)\n\nUNION\n\nSELECT employee_id \nFROM Salaries\nWHERE employee_id \nNOT IN (SELECT employee_id FROM Employees)\n```\n\nAt last ordering them by id.\n**COMPLETE CODE:**\n```\n# Write your MySQL query statement below\nSELECT employee_id \nFROM Employees\nWHERE employee_id \nNOT IN (SELECT employee_id FROM Salaries)\n\nUNION\n\nSELECT employee_id \nFROM Salaries\nWHERE employee_id \nNOT IN (SELECT employee_id FROM Employees)\n\nORDER BY employee_id;\n``` | 2 | 0 | ['Union Find', 'MySQL'] | 0 |
employees-with-missing-information | Faster than 96.64% | faster-than-9664-by-nisharathod231-41ss | MYSQL\n\nselect employee_id from employees\n where employee_id not in(\n select e.employee_id from employees as e, salaries as s\n where e.empl | NishaRathod231 | NORMAL | 2022-08-25T07:07:52.285084+00:00 | 2022-08-25T07:07:52.285120+00:00 | 300 | false | # MYSQL\n```\nselect employee_id from employees\n where employee_id not in(\n select e.employee_id from employees as e, salaries as s\n where e.employee_id = s.employee_id\n )\nunion\nselect employee_id from salaries\n where employee_id not in(\n select e.employee_id from employees as e, salaries as s\n where e.employee_id = s.employee_id\n )\norder by employee_id\n``` | 2 | 0 | ['Union Find', 'MySQL'] | 2 |
employees-with-missing-information | [MySQL] Simple and easy Implementation | mysql-simple-and-easy-implementation-by-f4du2 | ```\nselect employee_id\nfrom Employees\nwhere employee_id not in(select employee_id\n from Salaries)\n union\nselect emplo | overeckon | NORMAL | 2022-08-15T15:54:26.974499+00:00 | 2022-08-15T15:54:26.974567+00:00 | 128 | false | ```\nselect employee_id\nfrom Employees\nwhere employee_id not in(select employee_id\n from Salaries)\n union\nselect employee_id\nfrom Salaries\nwhere employee_id not in(select employee_id\n from Employees)\norder by employee_id; | 2 | 0 | ['Union Find', 'MySQL'] | 0 |
employees-with-missing-information | MYSQL: Very Easy Solution 100% working | mysql-very-easy-solution-100-working-by-osl6t | select employee_id from Employees where employee_id not in (select employee_id from Salaries)\nunion\nselect employee_id from Salaries where employee_id not in | Ganesh_2k1 | NORMAL | 2022-08-09T05:14:16.832694+00:00 | 2022-08-09T05:14:16.832731+00:00 | 245 | false | select employee_id from Employees where employee_id not in (select employee_id from Salaries)\nunion\nselect employee_id from Salaries where employee_id not in (select employee_id from Employees)\norder by employee_id; | 2 | 0 | ['Union Find'] | 0 |
employees-with-missing-information | MySQL Solution using UNION and NOT IN | Nested Query | mysql-solution-using-union-and-not-in-ne-5njy | STEPS\n- Select those id\'s from first table which are not in second table then select those id\'s from second table which are not in first table,\n- Take union | ayaankhan | NORMAL | 2022-07-26T15:38:17.478335+00:00 | 2022-07-26T15:38:17.478373+00:00 | 183 | false | #### STEPS\n- Select those id\'s from first table which are not in second table then select those id\'s from second table which are not in first table,\n- Take union of both result sets\n- Sort the result set by `employee_id`\n\n```\n\nSELECT\n e.employee_id \n FROM Employees as e \n WHERE e.employee_id \n NOT IN (SELECT employee_id FROM Salaries) \n UNION\nSELECT s.employee_id\n FROM Salaries as s\n WHERE s.employee_id\n NOT IN (SELECT employee_id FROM Employees)\n \n ORDER BY employee_id;\n``` | 2 | 0 | [] | 0 |
employees-with-missing-information | MySQL, left join + union | mysql-left-join-union-by-aat4f-a86z | \nselect e.employee_id\nfrom employees e\nleft join salaries s\non e.employee_id = s.employee_id\nwhere s.salary is null\n\nUNION\n | aat4f | NORMAL | 2022-07-25T16:49:21.217089+00:00 | 2022-07-25T16:49:21.217138+00:00 | 203 | false | ```\nselect e.employee_id\nfrom employees e\nleft join salaries s\non e.employee_id = s.employee_id\nwhere s.salary is null\n\nUNION\n\nselect s.employee_id\nfrom salaries s\nleft join employees e\non s.employee_id = e.employee_id\nwhere e.name is null\n\norder by 1\n``` | 2 | 0 | ['Union Find', 'MySQL'] | 0 |
employees-with-missing-information | Two MS SQL solution | two-ms-sql-solution-by-jarsonx-gww2 | Two solutions for MS SQL Server.\n\nThe first one seems quite long but it\'s more like a step-by-step approach, easy to follow and understand.\n\nWe create a ta | jarsonX | NORMAL | 2022-07-18T06:41:02.860716+00:00 | 2022-07-18T06:41:02.860745+00:00 | 206 | false | Two solutions for MS SQL Server.\n\nThe first one seems quite long but it\'s more like a step-by-step approach, easy to follow and understand.\n\nWe create a table based on Employees, join it with Salaries on \'employee_id\' from both. The question here is: what ids do we have in the first table that are not present in the second table? We do the same in reverse for Salaries and finally Union the two tables.\n\n```\nSELECT \n e.employee_id\nFROM \n Employees AS e\nLEFT JOIN\n Salaries AS s\n ON e.employee_id = s.employee_id\nWHERE s.employee_id IS NULL\n\nUNION\n\nSELECT \n s.employee_id\nFROM \n Salaries AS s\nLEFT JOIN\n Employees AS e\n ON s.employee_id = e.employee_id\nWHERE e.employee_id IS NULL\nORDER BY e.employee_id\n```\n\nOr we can achieve the same with COALESCE in more elegant way. COALESCE returns the first NOT NULL value.\n\n```\nSELECT\n COALESCE(e.employee_id, s.employee_id) AS employee_id\nFROM \n Employees AS e\nFULL JOIN\n Salaries AS s\n ON e.employee_id = s.employee_id\nWHERE\n e.name IS NULL OR s.salary IS NULL\nORDER BY employee_id\n``` | 2 | 0 | ['MS SQL Server'] | 0 |
employees-with-missing-information | Simple solution using Union | simple-solution-using-union-by-vaibhavna-09s8 | Write your MySQL query statement below\nselect employee_id from Employees where employee_id not in (select employee_id from Salaries) union\nselect employee_id | vaibhavnangia2001 | NORMAL | 2022-07-12T07:15:31.562404+00:00 | 2022-07-12T07:15:31.562448+00:00 | 269 | false | # Write your MySQL query statement below\nselect employee_id from Employees where employee_id not in (select employee_id from Salaries) union\nselect employee_id from Salaries where employee_id not in (select employee_id from Employees) order by employee_id | 2 | 0 | ['Union Find', 'MySQL'] | 0 |
employees-with-missing-information | MySQL || Simple Query || Using Union | mysql-simple-query-using-union-by-aarind-j5ck | \nselect employee_id from Employees where employee_id not in (select employee_id from Salaries)\nunion\nselect employee_id from Salaries where employee_id not i | aarindey | NORMAL | 2022-07-08T02:26:18.666730+00:00 | 2022-07-08T02:26:18.666757+00:00 | 195 | false | ```\nselect employee_id from Employees where employee_id not in (select employee_id from Salaries)\nunion\nselect employee_id from Salaries where employee_id not in (select employee_id from Employees) order by employee_id;\n``` | 2 | 0 | [] | 0 |
employees-with-missing-information | Logic Solution | logic-solution-by-faxa-unld | select employee_id from employees where employee_id not in(select employee_id from salaries)\nunion\nselect employee_id from salaries where employee_id not in | FaXa | NORMAL | 2022-07-06T04:09:34.903157+00:00 | 2022-07-06T04:09:34.903220+00:00 | 80 | false | select employee_id from employees where employee_id not in(select employee_id from salaries)\nunion\nselect employee_id from salaries where employee_id not in (select employee_id from employees) | 2 | 1 | ['Union Find', 'Oracle'] | 0 |
employees-with-missing-information | Easy solution with explanation | easy-solution-with-explanation-by-sebota-porz | \n# Find all the employee_ids that have salaries but without names\nSELECT s.employee_id FROM Salaries s LEFT JOIN Employees e \nON e.employee_id = s.employee_i | Sebotato | NORMAL | 2022-06-29T15:40:19.288320+00:00 | 2022-06-29T15:43:19.643361+00:00 | 206 | false | ```\n# Find all the employee_ids that have salaries but without names\nSELECT s.employee_id FROM Salaries s LEFT JOIN Employees e \nON e.employee_id = s.employee_id \nWHERE e.name IS NULL\n\n# Combine\nUNION\n\n# Find all the employee_ids that have names but without salaries\nSELECT e.employee_id FROM Employees e LEFT JOIN Salaries s\nON e.employee_id = s.employee_id \nWHERE s.salary IS NULL\n\n# Reorder the result by employee_id in the ascending order\nORDER BY employee_id;\n``` | 2 | 0 | ['Union Find'] | 0 |
employees-with-missing-information | EASY SOLUTION USING case | easy-solution-using-case-by-qalinle-ncsi | \nSELECT case\n WHEN e.employee_id is null THEN s.employee_id\n WHEN s.salary is NULL THEN e.employee_id\n END AS employee_id\nFROM employe | qalinle | NORMAL | 2022-06-29T03:58:10.813075+00:00 | 2022-06-29T03:58:10.813111+00:00 | 118 | false | ```\nSELECT case\n WHEN e.employee_id is null THEN s.employee_id\n WHEN s.salary is NULL THEN e.employee_id\n END AS employee_id\nFROM employees e FULL JOIN salaries s ON e.employee_id = s.employee_id\n\nWHERE e.employee_id is null or s.salary is NULL\n\nORDER BY employee_id\n``` | 2 | 0 | [] | 1 |
employees-with-missing-information | ✅ MySQL Solution, 2 Approaches | mysql-solution-2-approaches-by-sidsri199-w8zp | Approach 1:\n\nSELECT employee_id FROM Employees \nWHERE employee_id NOT IN (SELECT employee_id FROM Salaries)\nUNION\nSELECT employee_id FROM Salaries \nWHERE | sidsri1999 | NORMAL | 2022-06-06T16:08:42.547026+00:00 | 2022-06-06T16:08:42.547074+00:00 | 355 | false | **Approach 1:**\n```\nSELECT employee_id FROM Employees \nWHERE employee_id NOT IN (SELECT employee_id FROM Salaries)\nUNION\nSELECT employee_id FROM Salaries \nWHERE employee_id NOT IN (SELECT employee_id FROM Employees)\nORDER BY employee_id;\n```\n\n\n**Approach 2:**\n```\nSELECT Sub.employee_id FROM\n(SELECT e.employee_id, name, salary\nFROM Employees AS e \nLEFT JOIN \nSalaries AS s\nON e.employee_id = s.employee_id\nUNION\nSELECT s.employee_id, name, salary\nFROM Employees AS e \nRIGHT JOIN \nSalaries AS s\nON e.employee_id = s.employee_id) AS Sub\nWHERE Sub.name IS NULL OR Sub.salary IS NULL\nORDER BY Sub.Employee_id;\n``` | 2 | 0 | ['Union Find', 'MySQL'] | 0 |
timeout-cancellation | FULL EXPLANATION UNLIKE ANY OTHERS | full-explanation-unlike-any-others-by-sa-viqw | Intuition\nThe following problem and the next one " Interval Cancellation " ** represent an important concept in JavaScript . It\'s gonna be a long but full th | Sarah-2002 | NORMAL | 2023-07-06T05:07:01.623484+00:00 | 2023-07-06T05:12:17.933016+00:00 | 20,892 | false | # Intuition\nThe following problem and the next one **" Interval Cancellation " ** represent an important concept in JavaScript . It\'s gonna be a long but full through explanation so sit tight \uD83D\uDE06\uD83D\uDE06\uD83D\uDE06\n# **Motive :** Return a function after a specifc time only if you didn\'t call other function , if we called the other function then the first function shouldn\'t be called at all !!\n\n# Pre - Requistes : \n- Familarity with callback functions\n- Rest parameter\n- clearTimeout and setTimeout methods\n\nIf you know those , Congrats \uD83C\uDF89 ! You can further continue reading , if not then please go back and understand those pretty well .\n\n# A QUESTION YOU MIGHT BE ASKING : WHY DO I NEED TO USE clearTimeout and setTimeout ?\n\nIn Javascript controlling the flow and exceution of tasks , is quite crucial. The following 2 questions (**Execute Cancellable function with delay**) and (**Interval Cnacellation**) , posses a really really important concept , sit tight and read well \uD83D\uDE0A !\n\nBy using such methods , we can easily control timing and execution of a code , we can either delay or cancel them .\n\n# OKAY I SEE THEY\'RE IMPORTANT , BUT WHERE MIGHT I USE THEM ?\uD83E\uDD14\n\nThey\'re heavily used in scenarios such as :\n- Animation\n- Event Handling\n- Scheduling\n- Async Proggramming \n\n\n# OTHER QUESTION YOU MIGHT BE ASKING : \nHUM .... I THOUGHT I UNDERSTOOD THEM TURNS OUT I ONLY KNOW THE SYNTAX \n\nThat is alright , I will explain them fully don\'t worry ! \nLet\'s start with the **setTimeout** Method :\n\n- The function takes two parameters: a callback function and a delay value in milliseconds. The callback function represents the code we want to execute after the delay.\n- When we call setTimeout, it registers the callback function and starts a timer. After the specified delay, the JavaScript engine adds the callback function to the event queue.\n- In case you don\'t know what an event Queue is , the event queue is a data structure that holds tasks to be processed by the JavaScript runtime. When the call stack is empty (all synchronous code has finished executing), the runtime picks the next task from the event queue and executes it.\n- By using setTimeout, we introduce an asynchronous behavior in our code. This means that while the delay is counting down, the JavaScript engine can continue executing other code without waiting for the setTimeout callback to be invoked AND THIS IS REALLY IMPORTANT .\n\n# BUT WHY DID WE USE CLEARTIMEOUT ?\n\nWell , we need clearTimeout to cancel the scheduled execution before the delay expires.\nWe already know that setTimeout returns a unique identifier called a timeout ID , right ????\n\nWell , clearTimeout is another built-in function that cancels a timeout previously set with setTimeout. By passing the timeout ID to clearTimeout, we prevent the execution of the callback function and stop the timer .\n\n# Still not convinced ? Let\'s ask ourselves what would happen if we didn\'t use clearTimeout in our code ?!!\n\nUsing clearTimeout in conjunction with setTimeout provides us with the ability to control the execution of a scheduled function. When we set a timeout using setTimeout, the function inside it will run after the specified delay. However, by using clearTimeout, we can cancel the scheduled function before it runs which is what we want here .\n\n**In simpler terms, clearTimeout allows you to say, "Hey, hold on! Don\'t run that function yet!" It gives you the ability to pause or cancel the scheduled execution, providing a smoother and more responsive user experience in situations where dynamic control is required.**\n\n# CONCLUSION :\n Without clearTimeout, you wouldn\'t have the option to stop or cancel the execution of a scheduled function. It would always run regardless of any subsequent logic or conditions. By using clearTimeout, you have the power to manage and adjust the timing of your code, ensuring it behaves exactly as you need it to.\n\n\n\n# Approach\n- The code defines a function named "cancellable" that takes three parameters: "fn" (a function), "args" (an array of arguments), and "t" (a time delay in milliseconds).\n- Inside the "cancellable" function, a nested function named "cancelFn" is defined. This function is responsible for canceling the execution of the scheduled function.\n- The "cancelFn" function calls clearTimeout with the timer identifier to cancel the scheduled function execution.\n- The setTimeout function is used to schedule the execution of a function, which is passed as the first parameter, after the specified time delay (t).\n- The setTimeout function returns a timer identifier, which is stored in the "timer" variable.\n- The scheduled function (fn) is executed using the spread operator (...args) to pass the arguments array to the function.\n- Finally, the "cancelFn" function is returned from the "cancellable" function, allowing you to call it later to cancel the scheduled function if needed.\n\n# A beginner Level Question you might be asking : why did you define cancelFn t the top ? \nWell , The purpose of defining the "cancelFn" function at the top is to ensure that it is accessible within the scope of the "cancellable" function. This allows us to return the "cancelFn" function as part of the function\'s result, making it available for later use outside of the "cancellable" function. It\'s always a good practice to define functions at the top\n\n# FINAL CONCLUSION : \n\nThe concept of using clearTimeout and setTimeout provides a powerful mechanism for scheduling and canceling the execution of functions in JavaScript. By utilizing clearTimeout, you can prevent the scheduled function from running when it is no longer needed, allowing for more control and flexibility in managing asynchronous tasks. This concept is especially useful in scenarios where you want to delay the execution of code or schedule tasks to be performed in the future. Understanding and utilizing clearTimeout and setTimeout effectively can greatly enhance the efficiency and responsiveness of your JavaScript programs.\n\n**NOW THAT\'S IT HOPE YOU ENJOYED MY EXPLANATION , CHECK OUT THE OTHER SOLUTION FOR THE NEXT PROBLEM (**Interval Cnacellation**) they\'re both similar problems with slight difference tho \uD83E\uDD14\uD83D\uDE0A**\n\n\n# Code\n```\n/**\n * @param {Function} fn\n * @param {Array} args\n * @param {number} t\n * @return {Function}\n */\nconst cancellable = function(fn, args, t) {\n // cancelFn function//\n const cancelFn = function (){\n clearTimeout(timer);\n };\n const timer = setTimeout(()=>{\n fn(...args)\n }, t);\n return cancelFn ;\n};\n\n\n/**\n * const result = []\n *\n * const fn = (x) => x * 5\n * const args = [2], t = 20, cancelT = 50\n *\n * const log = (...argsArr) => {\n * result.push(fn(...argsArr))\n * }\n * \n * const cancel = cancellable(fn, args, t);\n * \n * setTimeout(() => {\n * cancel()\n * console.log(result) // [{"time":20,"returned":10}]\n * }, cancelT)\n */\n``` | 379 | 1 | ['Recursion', 'JavaScript'] | 37 |
timeout-cancellation | 🍞🍞🍞 Full thorough explanation || ✅ simple, beginner friendly | full-thorough-explanation-simple-beginne-4byf | Approach\nThis problem can be a bit confusing, as simple as the solution code is, so I will convey the problem in a step-by-step concrete manner. The following | TheGElCOgecko | NORMAL | 2023-06-10T06:18:49.618426+00:00 | 2023-06-27T00:26:49.048907+00:00 | 7,140 | false | # Approach\nThis problem can be a bit confusing, as simple as the solution code is, so I will convey the problem in a step-by-step concrete manner. The following example is how ```cancellable``` works:\n\nLet\'s say we want to execute a function ```foo``` defined as follows:\n```\nfunction foo(message) {\n console.log("If you see this message, I wasn\'t cancelled!!!");\n console.log("I want to tell the world this:");\n console.log(message);\n}\n```\nHowever, we want ```foo``` to be cancellable within the next 1000 milliseconds. And so, we call ```foo``` with ```var myMsg = cancellable(foo, "pineapple", 1000);```\n\nOnce ```myMsg``` is defined, it will take 1000 milliseconds to execute ```foo```. However, if ```myMsg``` is ever called before 1000 milliseconds, ```foo``` will be cancelled. Aka, if we do ```myMsg()``` 1000 milliseconds after we defined ```myMsg```, then ```foo``` will not execute.\n\u2014\nThe above is an example of ```cancellable``` in action. Now, to discuss how to implement it.\n\nFirst, let\'s set a timeout. We can do this as one normally would:\n```\nvar timeout = setTimeout(() =>\n fn(...args)\n, t)\n```\nNow the timeout is running. After this, let\'s define a way to clear this timeout.\n```\nvar cancelFn = () => clearTimeout(timeout);\n```\nNote, unlike ```timeout```, we did not execute ```cancelFn```. This is due to the fact that ```timeout``` is calling a function (the right side is formatted as ```function(somestuff)```), whereas ```cancelFn``` is simply the definition of a function (the right side is formatted as ```() => function(somestuff)```). If we instead wrote ```var cancelFn = clearTimeout(timeout)```, we would always cancel right after we start the timeout, and always fail to execute the function.\n\nFinally, let\'s have ```cancellable``` return ```cancelFn```. The reasoning behind this is as follows. We defined ```cancelFn```, but we need to be able to call it. By making ```cancellable``` return ```cancelFn```, the return line calls ```cancelFn```, which will cause ```cancelFn``` to execute (aka, it will cancel ```timeout```). And so, when we call cancellable, we execute the return line, thereby executing ```cancelFn```. Using the ```myMsg``` example above as demonstration, when we call ```myMsg()```, we return ```cancelFn```, which means we execute ```cancelFn```, thereby clearing ```timeout``` and cancelling ```foo```.\n\nAnd there you have it, a cancellable function!\n\n# Code\n```\nvar cancellable = function(fn, args, t) {\n // call setTimeout, which is set to call fn after t amount of time\n var timeout = setTimeout(() =>\n fn(...args)\n , t)\n\n // define a clearTimeout\n var cancelFn = () => clearTimeout(timeout);\n\n // When/if we call the function, it will return cancelFn,\n // and since the return line calls (and consequentially executes)\n // cancelFn, timeout will be cancelled, thereby cancelling fn\n return cancelFn;\n};\n```\nUPVOTE if this was helpful \uD83C\uDF5E\uD83C\uDF5E\uD83C\uDF5E | 98 | 0 | ['Design', 'JavaScript'] | 7 |
timeout-cancellation | Simple implementation | simple-implementation-by-cpcs-54gu | \n\n# Code\n\n/**\n * @param {Function} fn\n * @param {Array} args\n * @param {number} t\n * @return {Function}\n */\nvar cancellable = function(fn, args, t) {\ | cpcs | NORMAL | 2023-06-01T19:11:51.295491+00:00 | 2023-06-01T19:11:51.295521+00:00 | 3,702 | false | \n\n# Code\n```\n/**\n * @param {Function} fn\n * @param {Array} args\n * @param {number} t\n * @return {Function}\n */\nvar cancellable = function(fn, args, t) {\n var timeoutId = setTimeout(function() {\n fn.apply(null, args);\n }, t);\n\n var cancelFn = function() {\n clearTimeout(timeoutId);\n };\n\n return cancelFn;\n};\n\n\n/**\n * const result = []\n *\n * const fn = (x) => x * 5\n * const args = [2], t = 20, cancelT = 50\n *\n * const log = (...argsArr) => {\n * result.push(fn(...argsArr))\n * }\n * \n * const cancel = cancellable(fn, args, t);\n * \n * setTimeout(() => {\n * cancel()\n * console.log(result) // [{"time":20,"returned":10}]\n * }, cancelT)\n */\n``` | 12 | 0 | ['JavaScript'] | 1 |
timeout-cancellation | [TS] Boolean Flag, 75ms, 43.2MB | ts-boolean-flag-75ms-432mb-by-ajna2-tuwj | This problem requires little more than following the instructions, so we will:\n create a boolean flag willFnCall initially set to true;\n set a timeout in t mi | Ajna2 | NORMAL | 2023-06-02T18:42:02.588796+00:00 | 2023-06-02T18:42:02.588831+00:00 | 1,455 | false | This problem requires little more than following the instructions, so we will:\n* create a boolean flag `willFnCall` initially set to `true`;\n* set a timeout in `t` milliseconds to call `fn` with `args`, but only if `willFnCall` is still `true`;\n* `return` a function that sets the flag to `false` when called.\n\n# Complexity\n- Time complexity: $$O(1)$$\n- Space complexity: $$O(1)$$\n\n# Code\n```ts\nconst cancellable = (fn: Function, args: any[], t: number): Function => {\n let willFnCall = true;\n setTimeout(() => willFnCall && fn(...args), t);\n return () => willFnCall = false;\n};\n``` | 11 | 0 | ['TypeScript'] | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.