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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
replace-all-s-to-avoid-consecutive-repeating-characters | C++ beats 100%. use a, b or c to fill | c-beats-100-use-a-b-or-c-to-fill-by-cind-0q5v | \nclass Solution {\npublic:\n string modifyString(string s) {\n for (int i=0;i<s.size();i++){\n if (s[i] == \'?\'){\n if (i | cindy7b | NORMAL | 2020-12-02T06:06:28.238054+00:00 | 2020-12-02T06:06:28.238098+00:00 | 97 | false | ```\nclass Solution {\npublic:\n string modifyString(string s) {\n for (int i=0;i<s.size();i++){\n if (s[i] == \'?\'){\n if (i > 0 && i < s.size()-1){\n if ((s[i+1] ==\'a\' || s[i+1] ==\'b\') && (s[i-1] ==\'a\' || s[i-1] ==\'b\')){\n s[i] = \'c\';\n continue;\n }\n }\n \n if (i > 0 && s[i-1] ==\'a\'){\n s[i] = \'b\';\n continue;\n }else if (i > 0 && s[i-1] ==\'b\'){\n s[i] = \'a\';\n continue;\n }\n if (i < s.size()-1 && s[i+1] ==\'a\'){\n s[i] = \'b\';\n }else{\n s[i] = \'a\';\n }\n \n }\n }\n return s;\n }\n};\n``` | 1 | 0 | [] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | MY SQL || SOLUTION | my-sql-solution-by-_himanshu_12-rw7o | GROUP BY:\n\nselect actor_id, director_id \nfrom(\nselect actor_id,director_id, \ncount(timestamp) as cooperated \nfrom ActorDirector \ngroup by actor_id,direct | _himanshu_12 | NORMAL | 2022-10-01T10:58:16.218509+00:00 | 2022-10-01T11:12:39.520904+00:00 | 25,985 | false | ***GROUP BY:***\n```\nselect actor_id, director_id \nfrom(\nselect actor_id,director_id, \ncount(timestamp) as cooperated \nfrom ActorDirector \ngroup by actor_id,director_id) \ntable1\nwhere cooperated>=3;\n```\n\n***GROUP WITH HAVING CLAUSE:***\n```\nselect actor_id,director_id\nfrom ActorDirector \ngroup by actor_id,director_id\nHaving count(timestamp)>=3;\n```\n\n**EXPLANATION:**\n```\n+-------------+-------------+-------------+\n| actor_id | director_id | timestamp |\n+-------------+-------------+-------------+\n| 1 | 1 | 0 |\n| 1 | 1 | 1 |\n| 1 | 1 | 2 |\n| 1 | 2 | 3 |\n| 1 | 2 | 4 |\n| 2 | 1 | 5 |\n| 2 | 1 | 6 |\n+-------------+-------------+-------------+\n\nGroup by actor_id, director_id:\n+-------------+-------------+-------------+\n| actor_id | director_id | timestamp |\n+-------------+-------------+-------------+\n| 1 | 1 | 0, 1, 2 |\n| 1 | 2 | 3, 4 |\n| 2 | 1 | 5. 6 |\n+-------------+-------------+-------------+\n\nGroup by actor_id, director_id\nHaving count(timestamp)>=3\n\n| actor_id | director_id | count(timestamp) |\n+-------------+-------------+-------------+\n| 1 | 1 | 3 |\n| 1 | 2 | 2 |\n| 2 | 1 | 2 |\n+-------------+-------------+-------------+\n\nselect actor_id, director_id from:\n\n| actor_id | director_id \n+-------------+---------+\n| 1 | 1 |\n+-------------+---------+\n\n```\n\n***PLEASE UPVOTE IF YOU FIND IT A LITTLE BIT HELPFUL, MEANS A LOT ;)*** | 266 | 0 | ['MySQL'] | 19 |
actors-and-directors-who-cooperated-at-least-three-times | Concise MySQL Solution Using HAVING Clause | concise-mysql-solution-using-having-clau-2ty8 | SQL\nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(1) >= 3\n\n | zac4 | NORMAL | 2019-05-23T04:38:31.066287+00:00 | 2019-07-24T05:41:08.920158+00:00 | 17,342 | false | ```SQL\nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(1) >= 3\n```\n | 58 | 2 | [] | 5 |
actors-and-directors-who-cooperated-at-least-three-times | Simple Solution with GROUP BY | simple-solution-with-group-by-by-simanti-yd04 | \nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(timestamp)>=3\n | simantiri | NORMAL | 2021-01-19T18:35:08.144298+00:00 | 2021-01-19T18:35:08.144363+00:00 | 5,536 | false | ```\nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(timestamp)>=3\n``` | 31 | 0 | [] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Pandas vs SQL | Elegant & Short | All 30 Days of Pandas solutions ✅ | pandas-vs-sql-elegant-short-all-30-days-ggdsj | Complexity\n- Time complexity: O(n)\n- Space complexity: O(n)\n\n# Code\nPython []\ndef actors_and_directors(actor_director: pd.DataFrame) -> pd.DataFrame:\n | Kyrylo-Ktl | NORMAL | 2023-08-04T14:58:02.907714+00:00 | 2023-08-06T17:21:53.154178+00:00 | 3,783 | false | # Complexity\n- Time complexity: $$O(n)$$\n- Space complexity: $$O(n)$$\n\n# Code\n```Python []\ndef actors_and_directors(actor_director: pd.DataFrame) -> pd.DataFrame:\n stats = actor_director.groupby(\n [\'actor_id\', \'director_id\'],\n ).agg(\n count=(\'director_id\', \'count\'),\n ).reset_index()\n return stats[stats[\'count\'] >= 3][[\'actor_id\', \'director_id\']]\n```\n```SQL []\nSELECT actor_id,\n director_id\n FROM ActorDirector\n GROUP BY actor_id,\n director_id\nHAVING count(*) >= 3;\n```\n\n# Important!\n###### If you like the solution or find it useful, feel free to **upvote** for it, it will support me in creating high quality solutions)\n\n# 30 Days of Pandas solutions\n\n### Data Filtering \u2705\n- [Big Countries](https://leetcode.com/problems/big-countries/solutions/3848474/pandas-elegant-short-1-line/)\n- [Recyclable and Low Fat Products](https://leetcode.com/problems/recyclable-and-low-fat-products/solutions/3848500/pandas-elegant-short-1-line/)\n- [Customers Who Never Order](https://leetcode.com/problems/customers-who-never-order/solutions/3848527/pandas-elegant-short-1-line/)\n- [Article Views I](https://leetcode.com/problems/article-views-i/solutions/3867192/pandas-elegant-short-1-line/)\n\n\n### String Methods \u2705\n- [Invalid Tweets](https://leetcode.com/problems/invalid-tweets/solutions/3849121/pandas-elegant-short-1-line/)\n- [Calculate Special Bonus](https://leetcode.com/problems/calculate-special-bonus/solutions/3867209/pandas-elegant-short-1-line/)\n- [Fix Names in a Table](https://leetcode.com/problems/fix-names-in-a-table/solutions/3849167/pandas-elegant-short-1-line/)\n- [Find Users With Valid E-Mails](https://leetcode.com/problems/find-users-with-valid-e-mails/solutions/3849177/pandas-elegant-short-1-line/)\n- [Patients With a Condition](https://leetcode.com/problems/patients-with-a-condition/solutions/3849196/pandas-elegant-short-1-line-regex/)\n\n\n### Data Manipulation \u2705\n- [Nth Highest Salary](https://leetcode.com/problems/nth-highest-salary/solutions/3867257/pandas-elegant-short-1-line/)\n- [Second Highest Salary](https://leetcode.com/problems/second-highest-salary/solutions/3867278/pandas-elegant-short/)\n- [Department Highest Salary](https://leetcode.com/problems/department-highest-salary/solutions/3867312/pandas-elegant-short-1-line/)\n- [Rank Scores](https://leetcode.com/problems/rank-scores/solutions/3872817/pandas-elegant-short-1-line-all-30-days-of-pandas-solutions/)\n- [Delete Duplicate Emails](https://leetcode.com/problems/delete-duplicate-emails/solutions/3849211/pandas-elegant-short/)\n- [Rearrange Products Table](https://leetcode.com/problems/rearrange-products-table/solutions/3849226/pandas-elegant-short-1-line/)\n\n\n### Statistics \u2705\n- [The Number of Rich Customers](https://leetcode.com/problems/the-number-of-rich-customers/solutions/3849251/pandas-elegant-short-1-line/)\n- [Immediate Food Delivery I](https://leetcode.com/problems/immediate-food-delivery-i/solutions/3872719/pandas-elegant-short-1-line-all-30-days-of-pandas-solutions/)\n- [Count Salary Categories](https://leetcode.com/problems/count-salary-categories/solutions/3872801/pandas-elegant-short-1-line-all-30-days-of-pandas-solutions/)\n\n\n### Data Aggregation \u2705\n- [Find Total Time Spent by Each Employee](https://leetcode.com/problems/find-total-time-spent-by-each-employee/solutions/3872715/pandas-elegant-short-1-line-all-30-days-of-pandas-solutions/)\n- [Game Play Analysis I](https://leetcode.com/problems/game-play-analysis-i/solutions/3863223/pandas-elegant-short-1-line/)\n- [Number of Unique Subjects Taught by Each Teacher](https://leetcode.com/problems/number-of-unique-subjects-taught-by-each-teacher/solutions/3863239/pandas-elegant-short-1-line/)\n- [Classes More Than 5 Students](https://leetcode.com/problems/classes-more-than-5-students/solutions/3863249/pandas-elegant-short/)\n- [Customer Placing the Largest Number of Orders](https://leetcode.com/problems/customer-placing-the-largest-number-of-orders/solutions/3863257/pandas-elegant-short-1-line/)\n- [Group Sold Products By The Date](https://leetcode.com/problems/group-sold-products-by-the-date/solutions/3863267/pandas-elegant-short-1-line/)\n- [Daily Leads and Partners](https://leetcode.com/problems/daily-leads-and-partners/solutions/3863279/pandas-elegant-short-1-line/)\n\n\n### Data Aggregation \u2705\n- [Actors and Directors Who Cooperated At Least Three Times](https://leetcode.com/problems/actors-and-directors-who-cooperated-at-least-three-times/solutions/3863309/pandas-elegant-short/)\n- [Replace Employee ID With The Unique Identifier](https://leetcode.com/problems/replace-employee-id-with-the-unique-identifier/solutions/3872822/pandas-elegant-short-1-line-all-30-days-of-pandas-solutions/)\n- [Students and Examinations](https://leetcode.com/problems/students-and-examinations/solutions/3872699/pandas-elegant-short-1-line-all-30-days-of-pandas-solutions/)\n- [Managers with at Least 5 Direct Reports](https://leetcode.com/problems/managers-with-at-least-5-direct-reports/solutions/3872861/pandas-elegant-short/)\n- [Sales Person](https://leetcode.com/problems/sales-person/solutions/3872712/pandas-elegant-short-1-line-all-30-days-of-pandas-solutions/)\n\n\n | 28 | 0 | ['Python', 'Python3', 'MySQL', 'Pandas'] | 2 |
actors-and-directors-who-cooperated-at-least-three-times | [Pandas] || 2-step simple code with comments... | pandas-2-step-simple-code-with-comments-fht54 | \n\n# Code\n\nimport pandas as pd\n\ndef actors_and_directors(actor_director: pd.DataFrame) -> pd.DataFrame:\n # Group the data by actor_id and director_id, | sriganesh777 | NORMAL | 2023-08-22T18:10:26.167604+00:00 | 2023-08-22T18:10:26.167633+00:00 | 2,810 | false | \n\n# Code\n```\nimport pandas as pd\n\ndef actors_and_directors(actor_director: pd.DataFrame) -> pd.DataFrame:\n # Group the data by actor_id and director_id, and count the number of cooperations\n grouped = actor_director.groupby([\'actor_id\', \'director_id\']).size().reset_index(name=\'cooperation_count\')\n \n # Filter the pairs where the cooperation count is at least three\n filtered_pairs = grouped[grouped[\'cooperation_count\'] >= 3]\n \n return filtered_pairs[[\'actor_id\', \'director_id\']]\n\n``` | 15 | 0 | ['Pandas'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Simple and fast MySQL solution in one line | simple-and-fast-mysql-solution-in-one-li-mdfy | \nselect actor_id,director_id from ActorDirector group by 1,2 having count(*)>=3;\n\n\nNote: If you find it helpful then upvote. Cheers!! | harshitdwivedi01 | NORMAL | 2022-08-15T04:43:15.744584+00:00 | 2022-08-15T04:43:15.744623+00:00 | 2,238 | false | ```\nselect actor_id,director_id from ActorDirector group by 1,2 having count(*)>=3;\n```\n\nNote: If you find it helpful then upvote. Cheers!! | 14 | 0 | ['MySQL'] | 2 |
actors-and-directors-who-cooperated-at-least-three-times | Easy and Simple Approach😊 | easy-and-simple-approach-by-professional-clhg | \n# Code\n\nselect actor_id , director_id\nfrom ActorDirector\ngroup by actor_id,director_id\nhaving count(timestamp)>=3\n\n\n | ProfessionalMonk | NORMAL | 2023-08-02T02:56:49.741096+00:00 | 2023-08-02T02:56:49.741113+00:00 | 873 | false | \n# Code\n```\nselect actor_id , director_id\nfrom ActorDirector\ngroup by actor_id,director_id\nhaving count(timestamp)>=3\n```\n\n | 12 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Another Solution Using Window Function | another-solution-using-window-function-b-yttj | SELECT DISTINCT(actor_id), director_id\nFROM(\nSELECT actor_id, director_id , COUNT(timestamp) OVER (Partition by actor_id, director_id) as number_of_times\nFRO | joyjiang | NORMAL | 2022-04-11T00:56:14.044735+00:00 | 2022-04-11T00:56:14.044765+00:00 | 644 | false | SELECT DISTINCT(actor_id), director_id\nFROM(\nSELECT actor_id, director_id , COUNT(timestamp) OVER (Partition by actor_id, director_id) as number_of_times\nFROM ActorDirector) AS temp\nWHERE number_of_times >= 3 | 9 | 0 | [] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Solution Using MySQL GROUP BY and HAVING | solution-using-mysql-group-by-and-having-18uu | \nSELECT ACTOR_ID, DIRECTOR_ID\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(*) > 2\n | huangguoxin0512 | NORMAL | 2019-05-25T21:43:14.910879+00:00 | 2019-05-25T21:43:54.902710+00:00 | 5,317 | false | ```\nSELECT ACTOR_ID, DIRECTOR_ID\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(*) > 2\n``` | 9 | 0 | [] | 1 |
actors-and-directors-who-cooperated-at-least-three-times | MYSQL SOLN. | mysql-soln-by-hemant_1451-wbta | \n# Code\n\n# Write your MySQL query statement below\nSELECT ACTOR_ID, DIRECTOR_ID FROM ACTORDIRECTOR GROUP BY ACTOR_ID,DIRECTOR_ID HAVING COUNT(TIMESTAMP)>2;\n | Hemant_1451 | NORMAL | 2023-01-10T01:41:53.888213+00:00 | 2023-01-10T01:41:53.888250+00:00 | 3,152 | false | \n# Code\n```\n# Write your MySQL query statement below\nSELECT ACTOR_ID, DIRECTOR_ID FROM ACTORDIRECTOR GROUP BY ACTOR_ID,DIRECTOR_ID HAVING COUNT(TIMESTAMP)>2;\n``` | 8 | 0 | ['Database', 'MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | [MySQL] || GROUP BY || Beginner Friendly | mysql-group-by-beginner-friendly-by-coma-49uc | Write your MySQL query statement below\n\n\nSELECT actor_id , director_id\nFROM ActorDirector \nGROUP BY actor_id , director_id\nHAVING COUNT(timestamp)>=3;\n | comauro7511 | NORMAL | 2022-10-13T18:17:46.437931+00:00 | 2022-10-14T15:56:48.604253+00:00 | 2,506 | false | # Write your MySQL query statement below\n```\n\nSELECT actor_id , director_id\nFROM ActorDirector \nGROUP BY actor_id , director_id\nHAVING COUNT(timestamp)>=3;\n``` | 7 | 0 | ['MySQL'] | 2 |
actors-and-directors-who-cooperated-at-least-three-times | 1050. Actors and Directors Who Cooperated At Least Three Times | 1050-actors-and-directors-who-cooperated-5csm | ```\nSELECT actor_id, director_id FROM ActorDirector\nGROUP BY actor_id, director_id HAVING COUNT(timestamp)>2;\n | Spaulding_ | NORMAL | 2022-09-07T18:33:52.999003+00:00 | 2022-09-07T18:33:52.999045+00:00 | 979 | false | ```\nSELECT actor_id, director_id FROM ActorDirector\nGROUP BY actor_id, director_id HAVING COUNT(timestamp)>2;\n | 7 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Easy solution with HAVING COUNT(a =b) | easy-solution-with-having-counta-b-by-mm-3d4b | SELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(actor_id = director_id) >= 3; | mma4 | NORMAL | 2020-07-15T18:07:18.291568+00:00 | 2020-07-15T18:07:18.291599+00:00 | 1,207 | false | SELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(actor_id = director_id) >= 3; | 7 | 2 | [] | 2 |
actors-and-directors-who-cooperated-at-least-three-times | Easy my~SQL sol || think of group by / having / count | easy-mysql-sol-think-of-group-by-having-1p5gm | \nselect actor_id , director_id \nfrom actordirector \ngroup by actor_id ,director_id\nhaving count(*)>=3 ; \n\nThanks | abhi-kuks | NORMAL | 2022-09-12T11:12:59.749406+00:00 | 2022-09-12T11:12:59.749443+00:00 | 1,132 | false | ```\nselect actor_id , director_id \nfrom actordirector \ngroup by actor_id ,director_id\nhaving count(*)>=3 ; \n```\n***Thanks*** | 6 | 0 | [] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | MySQL - Slightly Optimized Solution | mysql-slightly-optimized-solution-by-xor-ls5y | \nSELECT actor_id as ACTOR_ID, director_id as DIRECTOR_ID\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING(COUNT(DISTINCT ActorDirector.timestamp) >= | xorobotxo | NORMAL | 2019-09-08T19:38:33.938459+00:00 | 2019-09-08T19:38:33.938528+00:00 | 2,184 | false | ```\nSELECT actor_id as ACTOR_ID, director_id as DIRECTOR_ID\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING(COUNT(DISTINCT ActorDirector.timestamp) >= 3);\n```\n\nMy original solution included a ```COUNT(*)``` which produced a result faster than only 5% of other submissions.\nAfter switching to counting only the distinct timestamps, the result proved faster than 42% of other submissions - which is still not ideal, but an interesting testiment to incremental query optimization. | 6 | 0 | [] | 3 |
actors-and-directors-who-cooperated-at-least-three-times | ✅ 100% EASY || FAST 🔥|| CLEAN SOLUTION 🌟 | 100-easy-fast-clean-solution-by-kartik_k-l6f6 | \n\n# Code\n\n/* Write your PL/SQL query statement below */\nSELECT actor_id, director_id FROM ActorDirector GROUP BY \n\nactor_id, director_id HAVING COUNT(dir | kartik_ksk7 | NORMAL | 2024-06-03T09:51:10.211090+00:00 | 2024-06-03T09:51:10.211108+00:00 | 522 | false | \n\n# Code\n```\n/* Write your PL/SQL query statement below */\nSELECT actor_id, director_id FROM ActorDirector GROUP BY \n\nactor_id, director_id HAVING COUNT(director_id) >=3 ;\n```\n\n | 5 | 0 | ['Database', 'Oracle'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Easy solution || MySQL || Pandas || Beats 100% !! | easy-solution-mysql-pandas-beats-100-by-t83dk | Code\n\n# Write your MySQL query statement below\nSELECT actor_id,director_id\nFROM ActorDirector \nGROUP BY actor_id,director_id\nHAVING count(timestamp)>=3;\n | prathams29 | NORMAL | 2023-08-01T17:02:50.362654+00:00 | 2023-08-01T17:02:50.362681+00:00 | 1,245 | false | # Code\n```\n# Write your MySQL query statement below\nSELECT actor_id,director_id\nFROM ActorDirector \nGROUP BY actor_id,director_id\nHAVING count(timestamp)>=3;\n```\n```\nimport pandas as pd\n\ndef actors_and_directors(actor_director: pd.DataFrame) -> pd.DataFrame:\n df = actor_director.groupby([\'actor_id\',\'director_id\']).agg(count =(\'director_id\',\'count\')).reset_index()\n df = df[df[\'count\'] >= 3]\n return df[[\'actor_id\',\'director_id\']]\n``` | 5 | 0 | ['MySQL', 'Pandas'] | 1 |
actors-and-directors-who-cooperated-at-least-three-times | Easy to understand || SQL | easy-to-understand-sql-by-yashwardhan24_-7x3y | 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 | yashwardhan24_sharma | NORMAL | 2023-03-09T05:59:41.122335+00:00 | 2023-03-09T05:59:41.122368+00:00 | 2,421 | 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 actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(timestamp)>=3;\n``` | 5 | 0 | ['Database', 'MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | 📌📌 easy solution :D || MySql ⚡ | easy-solution-d-mysql-by-maary-h51x | \nSELECT actor_id, director_id \nFROM\n (SELECT actor_id, director_id, COUNT(*) AS cnt\n FROM ActorDirector\n GROUP BY actor_id, director_id\n ) A | maary_ | NORMAL | 2023-03-05T00:49:07.037819+00:00 | 2023-03-05T22:43:15.245222+00:00 | 1,170 | false | ```\nSELECT actor_id, director_id \nFROM\n (SELECT actor_id, director_id, COUNT(*) AS cnt\n FROM ActorDirector\n GROUP BY actor_id, director_id\n ) AS t\nWHERE cnt >= 3;\n``` | 5 | 0 | ['MySQL', 'MS SQL Server'] | 2 |
actors-and-directors-who-cooperated-at-least-three-times | mysql, group by, having count(*) | mysql-group-by-having-count-by-nov05-riww | https://leetcode.com/submissions/detail/865539807/\n\n# Write your MySQL query statement below\nselect actor_id, director_id\nfrom ActorDirector\ngroup by actor | nov05 | NORMAL | 2022-12-26T03:56:19.670910+00:00 | 2022-12-26T03:56:19.670935+00:00 | 1,200 | false | https://leetcode.com/submissions/detail/865539807/\n```\n# Write your MySQL query statement below\nselect actor_id, director_id\nfrom ActorDirector\ngroup by actor_id, director_id\nhaving count(*) >= 3\n``` | 5 | 0 | [] | 2 |
actors-and-directors-who-cooperated-at-least-three-times | Simple Group By | simple-group-by-by-shivamleet07-55z0 | \nSELECT ACTOR_ID, DIRECTOR_ID\n\tFROM ActorDirector\nGROUP BY ACTOR_ID, DIRECTOR_ID\n\tHAVING COUNT(*) >= 3\n | shivamleet07 | NORMAL | 2022-07-30T17:57:13.344340+00:00 | 2022-07-30T17:57:13.344382+00:00 | 331 | false | ```\nSELECT ACTOR_ID, DIRECTOR_ID\n\tFROM ActorDirector\nGROUP BY ACTOR_ID, DIRECTOR_ID\n\tHAVING COUNT(*) >= 3\n``` | 5 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Optimised Approach || Group By | optimised-approach-group-by-by-vipul_05_-m7b1 | IntuitionWe need to find actor-director pairs who have collaborated on 3 or more movies. By grouping by both actor_id and director_id, we can count the number o | Vipul_05_Jain | NORMAL | 2025-01-23T07:37:44.224225+00:00 | 2025-01-23T07:37:44.224225+00:00 | 401 | false | # Intuition
We need to find actor-director pairs who have collaborated on 3 or more movies. By grouping by both actor_id and director_id, we can count the number of times each pair has worked together. Using HAVING COUNT(timestamp) >= 3, we filter the pairs with 3 or more collaborations.
# Approach
1. Group by both actor_id and director_id to aggregate data by actor-director pairs.
2. Count the number of collaborations (using timestamp or any other field that indicates a collaboration).
3. Filter the pairs where the count of collaborations is 3 or more using HAVING.
# Please upvote guys...!!
# Code
```mysql []
# Write your MySQL query statement below
SELECT actor_id, director_id
FROM ActorDirector
GROUP BY actor_id, director_id
HAVING COUNT(timestamp)>=3
``` | 4 | 0 | ['MySQL'] | 1 |
actors-and-directors-who-cooperated-at-least-three-times | MySQL Different Solution | With & Row_Number() Functions | | mysql-different-solution-with-row_number-do5g | \n# Code\nmysql []\nwith cte as (select *, row_number() over(partition by actor_id, director_id) as r from actordirector)\n\nselect distinct actor_id, director_ | Kamal_Kumar123 | NORMAL | 2024-09-08T05:28:43.517651+00:00 | 2024-09-08T05:28:43.517672+00:00 | 196 | false | \n# Code\n```mysql []\nwith cte as (select *, row_number() over(partition by actor_id, director_id) as r from actordirector)\n\nselect distinct actor_id, director_id from cte where r >= 3\n\n``` | 4 | 0 | ['MySQL'] | 1 |
actors-and-directors-who-cooperated-at-least-three-times | easy, clean pandas solution | easy-clean-pandas-solution-by-pooya_rost-4yjj | Intuition\neasy, clean pandas solution\n\n# Approach\ngroupby the data by combination of \'actor_id\' and \'director_id\' and count their occurance.\nnext, take | pooya_rostami_m | NORMAL | 2023-11-20T14:14:01.682892+00:00 | 2023-11-20T14:14:01.682926+00:00 | 452 | false | # Intuition\neasy, clean pandas solution\n\n# Approach\ngroupby the data by combination of \'actor_id\' and \'director_id\' and count their occurance.\nnext, take the ones that happen at least three times and show the \'actor_id\' and \'director_id\'\n\n# Complexity\n- Time complexity:\nnot sure\n\n- Space complexity:\nnot sure\n\n# Code\n```\nimport pandas as pd\n\ndef actors_and_directors(actor_director: pd.DataFrame) -> pd.DataFrame:\n return (\n actor_director\n .groupby(by=[\'actor_id\', \'director_id\'], as_index=False)\n .agg({\'timestamp\': \'count\'})\n .query(\'timestamp >= 3\')\n [[\'actor_id\', \'director_id\']]\n )\n``` | 4 | 0 | ['Pandas'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | 🔥 Pandas Easy and Concise Solution For Beginners 💯 | pandas-easy-and-concise-solution-for-beg-i6xl | \uD83D\uDD3C IF YOU FIND THIS POST HELPFUL PLEASE UPVOTE \uD83D\uDC4D\n\nimport pandas as pd\n\ndef actors_and_directors(actor_director: pd.DataFrame) -> pd.Dat | pniraj657 | NORMAL | 2023-08-28T11:39:15.827313+00:00 | 2023-08-28T11:39:15.827336+00:00 | 284 | false | **\uD83D\uDD3C IF YOU FIND THIS POST HELPFUL PLEASE UPVOTE \uD83D\uDC4D**\n```\nimport pandas as pd\n\ndef actors_and_directors(actor_director: pd.DataFrame) -> pd.DataFrame:\n \n result = actor_director.groupby([\'actor_id\', \'director_id\']).count().reset_index()\n \n return result[result[\'timestamp\']>=3][[\'actor_id\', \'director_id\']]\n```\n**Thank you for reading! \uD83D\uDE04 Comment if you have any questions or feedback.** | 4 | 0 | ['Python', 'Python3'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | MySQL Solution for Actors and Directors Who Cooperated At Least Three Times Problem | mysql-solution-for-actors-and-directors-et5q2 | Intuition\n Describe your first thoughts on how to solve this problem. \nThe intuition behind the given solution is to find actor-director pairs that have worke | Aman_Raj_Sinha | NORMAL | 2023-05-18T03:30:40.877203+00:00 | 2023-05-18T03:30:40.877302+00:00 | 966 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe intuition behind the given solution is to find actor-director pairs that have worked together in at least three movies. The approach involves grouping the rows in the ActorDirector table by actor_id and director_id, and then applying a condition in the HAVING clause to count the number of occurrences of each actor-director pair and filter out those with a count of less than three.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Group the rows in the ActorDirector table by actor_id and director_id.\n1. For each group, count the number of occurrences of the actor-director pair.\n1. Filter out the groups where the count is less than three.\n1. Return the actor_id and director_id values from the remaining groups.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nThe time complexity of this solution depends on the size of the ActorDirector table. The grouping operation requires scanning the ActorDirector table, which has a time complexity of O(n), where n is the number of rows in the ActorDirector table. Additionally, the count operation requires counting the occurrences of each actor-director pair, which also has a time complexity of O(n).\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nThe space complexity of this solution depends on the number of distinct actor_id and director_id pairs that satisfy the condition. The query requires storing the grouped actor_id and director_id values temporarily, so the space complexity is determined by the cardinality of these values.\n\n# Code\n```\n# Write your MySQL query statement below\nselect actor_id, director_id from ActorDirector\ngroup by actor_id, director_id\nhaving count(*) >= 3\n``` | 4 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | concise mysql solution using concat | concise-mysql-solution-using-concat-by-9-h0gs | \nselect actor_id, director_id from actordirector group by actor_id, director_id having count(concat(actor_id, director_id)) >= 3;\n | 96sayak | NORMAL | 2022-11-27T07:08:42.190316+00:00 | 2022-11-27T07:08:42.190342+00:00 | 434 | false | ```\nselect actor_id, director_id from actordirector group by actor_id, director_id having count(concat(actor_id, director_id)) >= 3;\n``` | 4 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | MS SQL Server 99.5% | ms-sql-server-995-by-guseowhtjs-bkc3 | \n/* Write your T-SQL query statement below */\nselect actor_id, director_id\n from actordirector\n group by actor_id, director_id\n having count(timestamp) > | guseowhtjs | NORMAL | 2022-07-28T12:48:49.545463+00:00 | 2022-07-28T12:48:49.545507+00:00 | 703 | false | ```\n/* Write your T-SQL query statement below */\nselect actor_id, director_id\n from actordirector\n group by actor_id, director_id\n having count(timestamp) > 2\n``` | 4 | 0 | ['MS SQL Server'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | ✅MySQL using "timestamp" | mysql-using-timestamp-by-ranbeer_singh-o1uj | \nSELECT\n actor_id,\n director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(timestamp) > 2\n | Ranbeer_Singh | NORMAL | 2022-07-16T03:38:19.911703+00:00 | 2022-07-16T03:38:19.911748+00:00 | 563 | false | ```\nSELECT\n actor_id,\n director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(timestamp) > 2\n``` | 4 | 0 | ['MySQL'] | 1 |
actors-and-directors-who-cooperated-at-least-three-times | Simple and Clean | simple-and-clean-by-nkalash-82e7 | SELECT ACTOR_ID, DIRECTOR_ID FROM ACTORDIRECTOR \nGROUP BY ACTOR_ID, DIRECTOR_ID \nHAVING COUNT(*) >= 3 | nkalash | NORMAL | 2022-05-24T07:45:02.931582+00:00 | 2022-05-24T07:45:02.931611+00:00 | 667 | false | SELECT ACTOR_ID, DIRECTOR_ID FROM ACTORDIRECTOR \nGROUP BY ACTOR_ID, DIRECTOR_ID \nHAVING COUNT(*) >= 3 | 4 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | MS SQL, MySQL and Oracle solution with GROUP BY and HAVING | ms-sql-mysql-and-oracle-solution-with-gr-1uiw | \nSELECT\n actor_id,\n director_id\nFROM\n ActorDirector\nGROUP BY\n actor_id,\n director_id\nHAVING \n COUNT(1) > 2\n | vazhev | NORMAL | 2022-04-23T20:40:09.170419+00:00 | 2022-04-23T20:40:09.170447+00:00 | 535 | false | ```\nSELECT\n actor_id,\n director_id\nFROM\n ActorDirector\nGROUP BY\n actor_id,\n director_id\nHAVING \n COUNT(1) > 2\n``` | 4 | 0 | ['MySQL', 'Oracle', 'MS SQL Server'] | 1 |
actors-and-directors-who-cooperated-at-least-three-times | Simple Query ✅ | With Proper Explanation 🤝 | simple-query-with-proper-explanation-by-r0not | IntuitionThe problem requires us to find all pairs of actors and directors who have worked together on at least three movies. This means we need to identify fre | NadeemMohammed | NORMAL | 2025-03-06T04:32:12.495492+00:00 | 2025-03-06T04:32:12.495492+00:00 | 212 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The problem requires us to find all pairs of actors and directors who have worked together on at least three movies. This means we need to identify frequent collaborations between actors and directors by counting how many times each pair appears in the ActorDirector table.
# Approach
<!-- Describe your approach to solving the problem. -->
1. Group the data: We use GROUP BY actor_id, director_id to group records based on the actor_id and director_id, ensuring that each unique pair is considered.
2. Count the occurrences: Using COUNT(*), we count how many times each actor-director pair appears in the table, which represents the number of movies they have worked on together.
3. Filter out pairs with fewer than 3 collaborations: The HAVING clause ensures that only pairs where COUNT(*) >= 3 are included in the result.
4. Select the required columns: Finally, we retrieve actor_id and director_id for the qualifying pairs.
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
If you found my solution helpful, I’d really appreciate it if you could give it an upvote! 🙌 Your support keeps me motivated to share more simple and efficient solutions. Thank you! 😊
# Code
```postgresql []
-- Write your PostgreSQL query statement below
SELECT actor_id, director_id
FROM ActorDirector
GROUP BY actor_id, director_id
HAVING COUNT(*) >= 3
``` | 3 | 0 | ['PostgreSQL'] | 1 |
actors-and-directors-who-cooperated-at-least-three-times | sql solution using case | sql-solution-using-case-by-sachin_kumar_-70iz | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Sachin_Kumar_Sharma | NORMAL | 2025-01-19T10:15:55.177903+00:00 | 2025-01-19T10:15:55.177903+00:00 | 84 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
```mysql []
select actor_id,director_id from
ActorDirector
group by actor_id,director_id
having sum(
case
when (actor_id/director_id) then 1
else 0
end
) >= 3
``` | 3 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Simple solution beats 99.9% | simple-solution-beats-999-by-rshikharev-49hw | Intuition\nThe task requires us to find pairs of actor_id and director_id who have collaborated at least three times. The initial thought is to group the data b | rshikharev | NORMAL | 2024-11-05T15:56:06.347046+00:00 | 2024-11-05T15:57:26.636779+00:00 | 485 | false | # Intuition\nThe task requires us to find pairs of `actor_id` and `director_id` who have collaborated at least three times. The initial thought is to group the data by each unique actor-director pair and then filter out the pairs that meet the collaboration threshold.\n\n# Approach\n1. **GROUP BY**: Use `GROUP BY actor_id, director_id` to aggregate rows for each actor-director pair.\n2. **COUNT & HAVING**: We use `COUNT(timestamp)` to determine the number of collaborations for each pair, and `HAVING COUNT(timestamp) >= 3` to retain only those pairs with at least three collaborations.\n\nThis approach is efficient, leveraging SQL\'s aggregation and filtering capabilities to retrieve the required data.\n\n# Complexity\n- **Time complexity**: $$O(n)$$, where $$n$$ is the number of rows in the `ActorDirector` table. The grouping and counting operations depend linearly on the size of the input.\n- **Space complexity**: $$O(k)$$, where $$k$$ is the number of unique actor-director pairs, as the grouping requires storage for each unique pair.\n\n# Code\n```mysql []\n# Write your MySQL query statement below\nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(timestamp) >= 3;\n``` | 3 | 0 | ['Database', 'MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Beginner Friendly Solution🌻 | beginner-friendly-solution-by-ravithemor-x4hr | Intuition:\nThe SQL query retrieves pairs of actor and director IDs from the ActorDirector table where the same actor has worked with the same director at least | ravithemore | NORMAL | 2023-11-17T06:33:45.050843+00:00 | 2023-11-17T06:33:45.050895+00:00 | 286 | false | **Intuition:**\nThe SQL query retrieves pairs of actor and director IDs from the `ActorDirector` table where the same actor has worked with the same director at least three times, based on the count of timestamps.\n\n**Approach:**\n1. The query groups the records in the `ActorDirector` table by pairs of `actor_id` and `director_id`.\n2. It then uses the `HAVING` clause to filter the grouped results, considering only those pairs where the count of timestamps (`count(timestamp)`) is greater than or equal to three.\n\n**Complexity:**\n- **Time complexity:** The time complexity is influenced by the grouping operation and the subsequent filtering based on the `HAVING` clause. Assuming appropriate indexing, the time complexity is likely to be O(n log n), where n is the number of rows in the `ActorDirector` table.\n\n- **Space complexity:** The space complexity is determined by the temporary storage required for the grouped results. Assuming m is the number of rows in the result set, the space complexity is O(m).\n\nKeep in mind that the actual performance may vary depending on the database engine, indexing, and the size of the `ActorDirector` table.\n\n# Code\n```\n# Write your MySQL query statement below\nselect actor_id, director_id from ActorDirector \ngroup by actor_id, director_id\nhaving count(timestamp)>=3;\n``` | 3 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Pandas | SQL | | Easy | Explained Step by Step | Actors & Directors Cooperated min Three Times | pandas-sql-easy-explained-step-by-step-a-f24v | see the successfully Accepted Submission\n\nimport pandas as pd\n\ndef actors_and_directors(actor_director: pd.DataFrame) -> pd.DataFrame:\n # Initially, we | Khosiyat | NORMAL | 2023-09-19T17:42:56.711696+00:00 | 2023-10-01T17:37:52.725957+00:00 | 135 | false | [see the successfully Accepted Submission](https://leetcode.com/submissions/detail/1053805243/)\n```\nimport pandas as pd\n\ndef actors_and_directors(actor_director: pd.DataFrame) -> pd.DataFrame:\n # Initially, we group \'actor_id\' and \'director_id\'.\n grouped_actor_director = actor_director.groupby([\'actor_id\', \'director_id\'])\n \n # In the next step, we count the number of \'actor_id\' and \'director_id\'.\n counted_actor_director = grouped_actor_director.size()\n \n # Then, we resets the index of the DataFrame.\n indexed_actor_director = counted_actor_director.reset_index(name=\'cooperated\')\n\n # After, that, we can filter the subquery to select rows where \'cooperated\' count is >= 3.\n filtered_actor_director = indexed_actor_director[indexed_actor_director[\'cooperated\'] >= 3]\n \n # Finally, we select and return a subset of \'actor_id\', \'director_id\' columns from the DataFrame .\n cooperated_actor_director = filtered_actor_director[[\'actor_id\', \'director_id\']]\n\n return cooperated_actor_director\n \n```\n\n**SQL**\n[see the successfully Accepted Submission](https://leetcode.com/submissions/detail/1061679792/)\n\n```\nSELECT actor_id, director_id \nFROM ActorDirector\n\nGROUP BY actor_id, director_id \nHAVING count(timestamp)>2;\n```\n\n\n```\n-- Select the "actor_id" and "director_id" columns from the "ActorDirector" table\n\n-- Specify the source table as "ActorDirector" from which data will be retrieved\nSELECT actor_id, director_id \n\nFROM ActorDirector\n\n-- Group the results by the combination of "actor_id" and "director_id"\nGROUP BY actor_id, director_id \n\n-- Apply a filter condition to the grouped results:\n-- We are selecting groups (combinations of actor and director) where the count of timestamps is greater than 2\nHAVING count(timestamp) > 2;\n\n```\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 |
actors-and-directors-who-cooperated-at-least-three-times | Pandas returning index (columns not duplicated for grouping and selecting items) | pandas-returning-index-columns-not-dupli-5due | Pandas returning index\nI like Panda\'s possibility to avoid repeating listing actor_id, director_id both for grouping and then final selecting items to return | garncarz | NORMAL | 2023-08-16T04:17:22.828501+00:00 | 2023-08-16T04:19:02.342820+00:00 | 327 | false | # Pandas returning index\nI like Panda\'s possibility to avoid repeating listing `actor_id`, `director_id` both for grouping and then final selecting items to return (as seen in the solution below).\n\n```\nimport pandas as pd\n\ndef actors_and_directors(actor_director: pd.DataFrame) -> pd.DataFrame:\n return (actor_director\n .groupby([\'actor_id\', \'director_id\'])\n [\'timestamp\'].count()\n .loc[lambda x: x >= 3]\n .index.to_frame()\n )\n```\n\n# Pandas using query\n```\nimport pandas as pd\n\ndef actors_and_directors(actor_director: pd.DataFrame) -> pd.DataFrame:\n return (actor_director\n .groupby([\'actor_id\', \'director_id\'], as_index=False)\n [\'timestamp\'].count()\n .query(\'timestamp >= 3\')\n [[\'actor_id\', \'director_id\']]\n )\n```\n\n# MySQL\n```\nselect\n actor_id,\n director_id\nfrom ActorDirector\ngroup by actor_id, director_id\nhaving count(`timestamp`) >= 3\n``` | 3 | 0 | ['MySQL', 'Pandas'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Simple MySQL Solution | simple-mysql-solution-by-abhradip_360-1d7y | 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 | abhradip_360 | NORMAL | 2023-06-07T12:47:30.591544+00:00 | 2023-06-07T12:47:30.591593+00:00 | 213 | 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 actor_id, director_id from ActorDirector \ngroup by actor_id, director_id\nhaving count(timestamp)>=3;\n\n``` | 3 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | MySQL Easy Solution ✅✅ | mysql-easy-solution-by-shubhamjain287-rwbd | 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 | Shubhamjain287 | NORMAL | 2023-03-08T05:40:25.132064+00:00 | 2023-03-08T05:40:25.132108+00:00 | 946 | 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 actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(timestamp)>=3\n``` | 3 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | MySQL Solution | mysql-solution-by-pranto1209-wknp | Code\n\n# Write your MySQL query statement below\nselect actor_id, director_id from ActorDirector \ngroup by actor_id, director_id having count(timestamp) >= 3; | pranto1209 | NORMAL | 2023-03-07T18:20:12.564667+00:00 | 2023-03-13T16:00:09.303804+00:00 | 848 | false | # Code\n```\n# Write your MySQL query statement below\nselect actor_id, director_id from ActorDirector \ngroup by actor_id, director_id having count(timestamp) >= 3;\n``` | 3 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Using Group by and Having Clause || Actors and Directors Who Cooperated At Least Three Times | using-group-by-and-having-clause-actors-232cs | 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 | himshrivas | NORMAL | 2023-01-26T08:44:53.468558+00:00 | 2023-01-26T08:44:53.468595+00:00 | 1,085 | 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 actor_id, director_id from ActorDirector group by actor_id,director_id having count(timestamp)>=3;\n```\nPlease upvote!! | 3 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | ✅✅Easy C++ Solution || Simple to Understand | easy-c-solution-simple-to-understand-by-0iv2f | \tselect actor_id, director_id\n\tfrom ActorDirector\n\tgroup by actor_id, director_id\n\thaving count(timestamp) >= 3;\nI hope that you\'ve found the solution | debav2 | NORMAL | 2022-10-07T19:25:07.181578+00:00 | 2022-10-08T06:59:20.637152+00:00 | 466 | false | \tselect actor_id, director_id\n\tfrom ActorDirector\n\tgroup by actor_id, director_id\n\thaving count(timestamp) >= 3;\nI hope that you\'ve found the solution useful.\nIn that case, please do upvote. Happy Coding :) | 3 | 0 | ['MySQL'] | 1 |
actors-and-directors-who-cooperated-at-least-three-times | Simple solution | Fast and easy | simple-solution-fast-and-easy-by-max_tar-40ae | \nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY 1, 2\nHAVING COUNT(1) > 2\n | max_tar | NORMAL | 2022-09-06T23:19:37.440725+00:00 | 2022-09-06T23:19:37.440756+00:00 | 1,003 | false | ```\nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY 1, 2\nHAVING COUNT(1) > 2\n``` | 3 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Simple 3 line code | mysql | simple-3-line-code-mysql-by-rohan_fasale-iwpp | select actor_id,director_id from actordirector\ngroup by director_id,actor_id\nhaving count(director_id)>=3 | Rohan_Fasale | NORMAL | 2022-09-02T18:07:20.865359+00:00 | 2022-09-02T18:07:20.865406+00:00 | 629 | false | select actor_id,director_id from actordirector\ngroup by director_id,actor_id\nhaving count(director_id)>=3 | 3 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | ✅MySQL || Beginner level || Faster than 98%||Simple-Short -Solution✅ | mysql-beginner-level-faster-than-98simpl-jqdv | 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-08-31T19:48:06.760521+00:00 | 2022-08-31T19:48:27.152623+00:00 | 276 | 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 Your runtime beats 98.12 % of mysql submissions.\n```\nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(timestamp)>=3\n```\n**Runtime:** 299 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 | 3 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | MSSQL | mssql-by-lavinamall-feeb | \nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(actor_id) > 2\n | lavinamall | NORMAL | 2022-07-22T01:08:35.155701+00:00 | 2022-07-22T01:08:35.155742+00:00 | 704 | false | ```\nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(actor_id) > 2\n``` | 3 | 0 | ['MS SQL Server'] | 1 |
actors-and-directors-who-cooperated-at-least-three-times | Group by the pair | group-by-the-pair-by-user5091-94d7 | \nselect actor_id, director_id\nfrom ActorDirector\ngroup by actor_id, director_id\nhaving count(timestamp)>2;\n | user5091 | NORMAL | 2021-11-13T18:05:58.729504+00:00 | 2021-11-13T18:05:58.729534+00:00 | 408 | false | ```\nselect actor_id, director_id\nfrom ActorDirector\ngroup by actor_id, director_id\nhaving count(timestamp)>2;\n``` | 3 | 0 | [] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Fast MS SQL solution | fast-ms-sql-solution-by-momo1621-ikzi | \nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHaving count(distinct timestamp) >= 3\n | Momo1621 | NORMAL | 2019-11-22T07:01:19.206096+00:00 | 2020-01-18T07:01:42.519627+00:00 | 784 | false | ```\nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHaving count(distinct timestamp) >= 3\n``` | 3 | 2 | [] | 2 |
actors-and-directors-who-cooperated-at-least-three-times | SELECT actor_id, director_id FROM ActorDirector GROUP BY actor_id, director_id HAVING COUNT(*)>=3; | select-actor_id-director_id-from-actordi-rqqv | null | Vishal1431 | NORMAL | 2025-02-04T19:09:39.811050+00:00 | 2025-02-04T19:09:39.811050+00:00 | 161 | false |
```mysql []
SELECT actor_id, director_id FROM ActorDirector
GROUP BY actor_id, director_id
HAVING COUNT(*)>=3;
``` | 2 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Group by clause in Postgres | group-by-clause-in-postgres-by-amoghamai-av1h | Code | AmoghaMayya | NORMAL | 2025-01-21T07:02:56.021501+00:00 | 2025-01-21T07:02:56.021501+00:00 | 162 | false |
# Code
```postgresql []
-- Write your PostgreSQL query statement below
select actor_id , director_id
from actordirector
group by actor_id , director_id
having count(*) > 2;
``` | 2 | 0 | ['PostgreSQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | SQL | sql-by-kanvapuri_sai_praneetha-bss9 | Code\n\nSELECT actor_id, director_id \nFROM ActorDirector \nGROUP BY actor_id, director_id \nHAVING count(*)>= 3;\n | kanvapuri_sai_praneetha | NORMAL | 2024-08-10T02:59:19.129511+00:00 | 2024-08-10T02:59:19.129549+00:00 | 486 | false | # Code\n```\nSELECT actor_id, director_id \nFROM ActorDirector \nGROUP BY actor_id, director_id \nHAVING count(*)>= 3;\n``` | 2 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | (Pandas) 1-line | pandas-1-line-by-qeetcode-id63 | \ndef actors_and_directors(actor_director: pd.DataFrame) -> pd.DataFrame:\n return actor_director.groupby(by=["actor_id", "director_id"], as_index=False).siz | qeetcode | NORMAL | 2023-08-17T20:19:20.000460+00:00 | 2023-08-17T20:19:20.000511+00:00 | 321 | false | ```\ndef actors_and_directors(actor_director: pd.DataFrame) -> pd.DataFrame:\n return actor_director.groupby(by=["actor_id", "director_id"], as_index=False).size().query("size >= 3").drop(labels="size", axis=1); \n``` | 2 | 0 | [] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Explained | Group By With Having | SQL and Pandas | explained-group-by-with-having-sql-and-p-vy3w | My SQL\nYou can add conditions to group by clause by using having clause.\nAdd actor_id, director_id to group by because they are being selected for showing. An | hridoy100 | NORMAL | 2023-08-12T06:58:21.816075+00:00 | 2023-08-12T06:58:21.816098+00:00 | 1,311 | false | # My SQL\nYou can add conditions to `group by` clause by using `having` clause.\nAdd `actor_id, director_id` to group by because they are being selected for showing. Anything that\'s not inside an aggregate function (`count()`, `avg()`, `max()`, etc.) and needs to be shown as output must be written inside `GROUP BY` clause.\n\n``` SQL []\n# Write your MySQL query statement below\nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING count(timestamp)>=3\n```\n\n# Pandas\n\nIf you understand the SQL clearly, you will be able to come up with the following solution.\n\n``` python3 []\nimport pandas as pd\n\ndef actors_and_directors(ad: pd.DataFrame) -> pd.DataFrame:\n df = ad.groupby([\'actor_id\', \'director_id\']).count().reset_index()\n return df[df[\'timestamp\']>=3][[\'actor_id\', \'director_id\']]\n``` | 2 | 0 | ['MySQL', 'Pandas'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | MySQL Solution | mysql-solution-by-triyambkeshtiwari-f3v1 | 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 | triyambkeshtiwari | NORMAL | 2023-08-10T15:55:55.331508+00:00 | 2023-08-10T15:55:55.331536+00:00 | 423 | 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 actor_id , director_id\nfrom ActorDirector\ngroup by actor_id,director_id\nhaving count(timestamp)>=3\n``` | 2 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | ✔MySQL Simple Solution✔ | mysql-simple-solution-by-arth_anaya-oal2 | 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 | Arth_Anaya | NORMAL | 2023-04-20T14:17:14.471908+00:00 | 2023-04-20T14:17:14.471940+00:00 | 373 | 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\n\nselect\n actor_id, director_id\nfrom actordirector\ngroup by actor_id, director_id\nhaving count(actor_id=director_id) >= 3\n``` | 2 | 0 | ['MySQL'] | 2 |
actors-and-directors-who-cooperated-at-least-three-times | Easy Solution | MySQL👀🥷 | easy-solution-mysql-by-dipesh_12-0pnc | 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 | dipesh_12 | NORMAL | 2023-04-12T15:32:16.944482+00:00 | 2023-04-12T15:32:16.944516+00:00 | 4,202 | 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 actor_id,director_id from ActorDirector group by actor_id,director_id having count(*)>=3;\n``` | 2 | 0 | ['MySQL'] | 1 |
actors-and-directors-who-cooperated-at-least-three-times | SQL Server CLEAN & EASY | sql-server-clean-easy-by-rhazem13-29oq | \nSELECT ad.actor_id, ad.director_id\nFROM ActorDirector ad\nJOIN (\n SELECT actor_id, director_id\n FROM ActorDirector\n GROUP BY actor_id, director_id\n H | rhazem13 | NORMAL | 2023-03-17T08:37:18.457507+00:00 | 2023-03-17T08:37:18.457540+00:00 | 1,845 | false | ```\nSELECT ad.actor_id, ad.director_id\nFROM ActorDirector ad\nJOIN (\n SELECT actor_id, director_id\n FROM ActorDirector\n GROUP BY actor_id, director_id\n HAVING COUNT(*) >= 3\n) ad2 ON ad.actor_id = ad2.actor_id AND ad.director_id = ad2.director_id\nGROUP BY ad.actor_id, ad.director_id\n\n``` | 2 | 0 | [] | 1 |
actors-and-directors-who-cooperated-at-least-three-times | MYSQL || Easy approach | mysql-easy-approach-by-mrigank_2003-pga0 | \n# Code\n\n# Write your MySQL query statement below\nselect actor_id, director_id from ActorDirector group by actor_id, director_id having count(timestamp)>=3; | mrigank_2003 | NORMAL | 2023-03-14T04:20:37.121636+00:00 | 2023-03-14T04:20:37.121682+00:00 | 3,207 | false | \n# Code\n```\n# Write your MySQL query statement below\nselect actor_id, director_id from ActorDirector group by actor_id, director_id having count(timestamp)>=3;\n``` | 2 | 0 | ['MySQL'] | 1 |
actors-and-directors-who-cooperated-at-least-three-times | MySQL Solution | mysql-solution-by-abstractconnoisseurs-tc7h | Code\n\nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(1) >= 3\n | abstractConnoisseurs | NORMAL | 2023-01-27T09:07:51.616774+00:00 | 2023-01-27T09:07:51.616806+00:00 | 702 | false | # Code\n```\nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(1) >= 3\n``` | 2 | 0 | ['Database', 'MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Group by & Having | group-by-having-by-bejoysekhar-5edb | \nselect actor_id, director_id from actordirector group by actor_id, director_id having count(*) >= 3 \n | bejoysekhar | NORMAL | 2022-10-07T02:08:26.106611+00:00 | 2022-10-07T02:08:26.106657+00:00 | 483 | false | ```\nselect actor_id, director_id from actordirector group by actor_id, director_id having count(*) >= 3 \n``` | 2 | 0 | [] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Easy & Concise MySQL Solution using HAVING Clause | easy-concise-mysql-solution-using-having-4z9p | Do upvote the solution to keep me motivated , incase you liked it ;)\n\n\nSELECT actor_id,director_id \nFROM ActorDirector \nGROUP BY actor_id,director_id\nHAVI | vartika23_02 | NORMAL | 2022-09-01T05:38:48.754473+00:00 | 2022-09-01T05:39:01.563709+00:00 | 58 | false | **Do upvote the solution to keep me motivated , incase you liked it ;)**\n\n```\nSELECT actor_id,director_id \nFROM ActorDirector \nGROUP BY actor_id,director_id\nHAVING count(actor_id=director_id)>=3;\n``` | 2 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | MS SQL | Easy | ms-sql-easy-by-nikhil_katoch-6v02 | \nselect actor_id, director_id\nfrom ActorDirector\ngroup by director_id,actor_id\nhaving count(director_id)>=3\n | nikhil_katoch | NORMAL | 2022-08-28T13:17:01.522615+00:00 | 2022-08-28T13:17:01.522645+00:00 | 577 | false | ```\nselect actor_id, director_id\nfrom ActorDirector\ngroup by director_id,actor_id\nhaving count(director_id)>=3\n``` | 2 | 0 | ['MS SQL Server'] | 1 |
actors-and-directors-who-cooperated-at-least-three-times | Easy To Understand Solution | easy-to-understand-solution-by-inferno08-r113 | \nSELECT DISTINCT t.actor_id, t.director_id FROM ActorDirector t\nGROUP BY t.actor_id , t.director_id\nHAVING COUNT(t.timestamp) >= 3\n | inferno080 | NORMAL | 2022-08-08T07:18:27.292902+00:00 | 2022-08-08T07:18:27.292940+00:00 | 169 | false | ```\nSELECT DISTINCT t.actor_id, t.director_id FROM ActorDirector t\nGROUP BY t.actor_id , t.director_id\nHAVING COUNT(t.timestamp) >= 3\n``` | 2 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | 2 MySQL Solutions: GROUP BY & RANK() | 2-mysql-solutions-group-by-rank-by-farya-1h5t | 1. Using GROUP BY and HAVING clause (the simplest one)\n\nSELECT a.actor_id, a.director_id\nFROM ActorDirector a\nGROUP BY a.actor_id, a.director_id\nHAVING COU | faryar251 | NORMAL | 2022-07-26T10:52:19.452540+00:00 | 2022-07-26T10:54:12.445453+00:00 | 125 | false | ### 1. Using `GROUP BY` and `HAVING` clause (the simplest one)\n```\nSELECT a.actor_id, a.director_id\nFROM ActorDirector a\nGROUP BY a.actor_id, a.director_id\nHAVING COUNT(timestamp) > 2\n```\n\n### 2. Using `RANK() OVER` clause\n```\nSELECT a1.actor_id, a1.director_id\nFROM (\n SELECT \n a.actor_id, \n a.director_id,\n RANK() OVER (PARTITION BY a.actor_id, a.director_id\n ORDER BY a.timestamp) AS \'coop_count\'\n FROM ActorDirector a) a1\nWHERE a1.coop_count = 3\n```\n\nThanks for reading!\nIf there\'s any error or doubt, do comment. Feedbacks are always appreciated!! | 2 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | [ MYSQL ] ✅✅ Simple MYSQL Solution Using Having Count Clause || Group By 🥳✌👍 | mysql-simple-mysql-solution-using-having-1lmv | If You like the Solution, Don\'t Forget To UpVote Me, Please UpVote! \uD83D\uDD3C\uD83D\uDE4F\n# Runtime: 376 ms, faster than 69.66% of MySQL online submissions | ashok_kumar_meghvanshi | NORMAL | 2022-07-16T18:25:20.836308+00:00 | 2022-07-16T18:25:20.836345+00:00 | 227 | false | # If You like the Solution, Don\'t Forget To UpVote Me, Please UpVote! \uD83D\uDD3C\uD83D\uDE4F\n# Runtime: 376 ms, faster than 69.66% of MySQL online submissions for Actors and Directors Who Cooperated At Least Three Times.\n# Memory Usage: 0B, less than 100.00% of MySQL online submissions for Actors and Directors Who Cooperated At Least Three Times.\n\n\tSELECT ACTOR_ID, DIRECTOR_ID\n\tFROM ACTORDIRECTOR\n\tGROUP BY ACTOR_ID, DIRECTOR_ID\n\tHAVING COUNT(TIMESTAMP) > 2 | 2 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Simplest | simplest-by-suraj21193-cf09 | ```\n/ Write your T-SQL query statement below /\nSELECT actor_id, director_id\nFROM ActorDirector \n GROUP BY actor_id, director_id\n Having COUNT(ti | suraj21193 | NORMAL | 2022-06-23T14:21:29.311327+00:00 | 2022-06-23T14:23:18.940728+00:00 | 163 | false | ```\n/* Write your T-SQL query statement below */\nSELECT actor_id, director_id\nFROM ActorDirector \n GROUP BY actor_id, director_id\n Having COUNT(timestamp) >=3 | 2 | 0 | [] | 1 |
actors-and-directors-who-cooperated-at-least-three-times | Using GROUP BY and HAVING | using-group-by-and-having-by-supratim_co-trpi | \nSELECT actor_id, director_id from ActorDirector GROUP BY actor_id, director_id HAVING COUNT(*)>2;\n | supratim_code | NORMAL | 2022-05-29T16:17:28.563434+00:00 | 2022-05-29T16:17:28.563472+00:00 | 305 | false | ```\nSELECT actor_id, director_id from ActorDirector GROUP BY actor_id, director_id HAVING COUNT(*)>2;\n``` | 2 | 0 | [] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | GROUP BY and HAVING | Very Easy Solution | group-by-and-having-very-easy-solution-b-crq0 | \nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(*) >= 3;\n | ajinkya2000 | NORMAL | 2022-05-18T10:23:18.321399+00:00 | 2022-05-18T10:23:18.321439+00:00 | 178 | false | ```\nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(*) >= 3;\n``` | 2 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | mysql groupby and having | mysql-groupby-and-having-by-sulaymon-dev-xodz | \nselect actor_id,director_id from ActorDirector group by actor_id,director_id having count(*)>=3\n | Sulaymon-Dev20 | NORMAL | 2022-04-21T18:47:17.152177+00:00 | 2022-04-21T18:47:17.152219+00:00 | 107 | false | ```\nselect actor_id,director_id from ActorDirector group by actor_id,director_id having count(*)>=3\n``` | 2 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | simple | simple-by-du0118-wimp | select actor_id, director_id\nfrom actordirector\ngroup by actor_id, director_id\nhaving count(actor_id = director_id) >= 3\n; | DU0118 | NORMAL | 2022-03-05T20:51:42.484594+00:00 | 2022-03-05T20:51:42.484626+00:00 | 184 | false | select actor_id, director_id\nfrom actordirector\ngroup by actor_id, director_id\nhaving count(actor_id = director_id) >= 3\n; | 2 | 0 | [] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | mySQL | having, group by | explained | mysql-having-group-by-explained-by-anhtr-7919 | `\nselect actor_id, director_id\nfrom ActorDirector \n#return pair of (actor_id, director_id) \ngroup by actor_id, director_id\nhaving count(*) >= 3\n#having: c | anhtran114 | NORMAL | 2022-01-12T21:12:03.739409+00:00 | 2022-01-12T21:12:20.804532+00:00 | 468 | false | ```\nselect actor_id, director_id\nfrom ActorDirector \n#return pair of (actor_id, director_id) \ngroup by actor_id, director_id\nhaving count(*) >= 3\n#having: condition \n#count(*) means count all include NULL cases\n;\n``\n | 2 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Group By and Having () | group-by-and-having-by-yzhou2018-knnj | select actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nhaving count(timestamp)>=3; | yzhou2018 | NORMAL | 2021-11-29T02:31:26.671563+00:00 | 2021-11-29T02:31:26.671595+00:00 | 348 | false | select actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nhaving count(timestamp)>=3; | 2 | 0 | [] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Simple MySql Solution ,faster than 93.77% of MySQL online submissions | simple-mysql-solution-faster-than-9377-o-ij4n | \nSelect actor_id,director_id from actordirector\ngroup by actor_id,director_id\nhaving count(director_id)>=3\n | user8447f | NORMAL | 2021-10-20T12:55:34.160217+00:00 | 2021-10-20T12:55:34.160246+00:00 | 384 | false | ```\nSelect actor_id,director_id from actordirector\ngroup by actor_id,director_id\nhaving count(director_id)>=3\n``` | 2 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | MySQL | mysql-by-vincentt126-6xc0 | run time 342s\nselect actor_id, director_id\nfrom actordirector\ngroup by actor_id, director_id\nhaving count(*)>=3\n\nrun time 448s\n\nselect actor_id, directo | vincentt126 | NORMAL | 2021-06-18T18:08:35.769363+00:00 | 2021-06-18T18:09:22.743008+00:00 | 218 | false | run time 342s\n```select actor_id, director_id\nfrom actordirector\ngroup by actor_id, director_id\nhaving count(*)>=3\n```\nrun time 448s\n```\nselect actor_id, director_id\nfrom actordirector\ngroup by actor_id, director_id\nhaving count(timestamp)>=3\n```\n | 2 | 0 | [] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | EASIEST SOLUTION IN MySQL | easiest-solution-in-mysql-by-hitarthshah-q1zt | IntuitionUPVOTE IF YOU FIND IT HELPFUL.ApproachComplexity
Time complexity:
Space complexity:
Code | HITARTHSHAH2211 | NORMAL | 2025-04-01T04:29:57.633519+00:00 | 2025-04-01T04:29:57.633519+00:00 | 115 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
UPVOTE IF YOU FIND IT HELPFUL.
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
```mysql []
# Write your MySQL query statement below
select actor_id,director_id from ActorDirector
group by actor_id,director_id
having count(timestamp)>=3;
``` | 1 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Easy Solution | Using Group by and Having | easy-solution-using-group-by-and-having-83lhc | Code | Aminour_Islam | NORMAL | 2025-01-15T13:44:20.830085+00:00 | 2025-01-15T13:44:20.830085+00:00 | 33 | false |
# Code
```mysql []
# Write your MySQL query statement below
select actor_id, director_id
from ActorDirector
group by actor_id, director_id
having count(*) >= 3;
``` | 1 | 0 | ['Database', 'MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | 👉🏻FAST AND EASY TO UNDERSTAND SOLUTION || MySQL | fast-and-easy-to-understand-solution-mys-3je0 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | djain7700 | NORMAL | 2025-01-08T18:05:14.577196+00:00 | 2025-01-08T18:05:14.577196+00:00 | 111 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
```mysql []
# Write your MySQL query statement below
SELECT actor_id,director_id
FROM ActorDirector
GROUP BY actor_id,director_id
HAVING COUNT(*)>=3
``` | 1 | 0 | ['Database', 'MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Easy Solution | easy-solution-by-vittalnesaragi-a3dw | \n\n# Code\noraclesql []\n/* Write your PL/SQL query statement below */\nSELECT ACTOR_ID,DIRECTOR_ID FROM ACTORDIRECTOR GROUP BY ACTOR_ID,DIRECTOR_ID HAVING COU | VittalNesaragi | NORMAL | 2024-12-02T09:16:30.070593+00:00 | 2024-12-02T09:16:30.070621+00:00 | 219 | false | \n\n# Code\n```oraclesql []\n/* Write your PL/SQL query statement below */\nSELECT ACTOR_ID,DIRECTOR_ID FROM ACTORDIRECTOR GROUP BY ACTOR_ID,DIRECTOR_ID HAVING COUNT(*)>=3;\n``` | 1 | 0 | ['MySQL', 'Oracle'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Beginner-Friendly Solution Using SQL Server || Clear | beginner-friendly-solution-using-sql-ser-43ao | 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-06-03T14:48:50.375640+00:00 | 2024-06-03T14:48:50.375669+00:00 | 331 | 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 actor_id, director_id\nfrom ActorDirector\ngroup by actor_id, director_id\nhaving count(timestamp) >= 3\n``` | 1 | 0 | ['MS SQL Server'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Ezzy Pzzy ✌️ 🤞|| Oracle Solution || BEGINNER FRIENDLY ||Complete Explanation|| Group by with count | ezzy-pzzy-oracle-solution-beginner-frien-sm0r | Intuition\nAs the problem requires pair of two column and its count. Therefore,my first thought is to use Group by. \n\n# Approach\nTo use group by on two colum | Ninja_ | NORMAL | 2023-09-07T11:03:56.178979+00:00 | 2023-09-07T11:03:56.179004+00:00 | 63 | false | # Intuition\nAs the problem requires pair of two column and its count. Therefore,my first thought is to use Group by. \n\n# Approach\nTo use group by on two columns with count we can use:\ngroup by(col1, col2) having count(1)>2\nThis will first collect all the pairs of actors and directors and then count their frequency and return the rows where the frequency is greater then 2 or atleast 3\n\n\n# Code\n```\n/* Write your PL/SQL query statement below */\n\nselect actor_id, director_id from ActorDirector group by actor_id, director_id having count(1)>2;\n\n\n\n```\n\n\n | 1 | 0 | ['Oracle'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | PLSQL solution using having count() | plsql-solution-using-having-count-by-dib-rsnd | 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 | DibyaJyoti_Sarmah | NORMAL | 2023-06-06T07:50:20.039113+00:00 | 2023-06-06T07:50:20.039151+00:00 | 263 | 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 actor_id , director_id from ActorDirector \nhaving count(1) >= 3\ngroup by actor_id , director_id\n``` | 1 | 0 | ['Oracle'] | 1 |
actors-and-directors-who-cooperated-at-least-three-times | Simple Code using HAVING : Actors and Directors Who Cooperated At Least Three Times | simple-code-using-having-actors-and-dire-6zy1 | Code\n\n# Write your MySQL query statement below\nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(timestamp) >=3; | kchheda97 | NORMAL | 2023-05-24T18:06:12.912909+00:00 | 2023-05-24T18:07:06.198097+00:00 | 34 | false | # Code\n```\n# Write your MySQL query statement below\nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(timestamp) >=3;\n``` | 1 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Simple solution with GROUP BY | simple-solution-with-group-by-by-iliaavd-2i4f | Approach\nGROUP BY + HAVING\n\n# Code\n\nSELECT actor_id, director_id FROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(*) >= 3\n | IliaAvdeev | NORMAL | 2023-04-30T17:42:16.922351+00:00 | 2023-04-30T17:42:16.922411+00:00 | 5 | false | # Approach\nGROUP BY + HAVING\n\n# Code\n```\nSELECT actor_id, director_id FROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(*) >= 3\n``` | 1 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | 1050. Actors and Directors Who Cooperated At Least Three Times | MySQL | 1050-actors-and-directors-who-cooperated-1i4l | \n Add your space complexity here, e.g. O(n) \n\n# Code\n\n# Write your MySQL query statement below\nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY | codewithusama | NORMAL | 2023-03-26T13:05:13.176331+00:00 | 2023-03-26T13:05:13.176366+00:00 | 77 | false | \n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n# Write your MySQL query statement below\nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(*) >= 3;\n``` | 1 | 0 | ['C++', 'Java', 'MySQL', 'Oracle', 'MS SQL Server'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | MySQL || GROUP BY || BEGINNER FRIENDLY || EASY SOLUTION | mysql-group-by-beginner-friendly-easy-so-qq2c | \nSELECT actor_id,director_id FROM ActorDirector \nGROUP BY actor_id,director_id \nhaving count(*) >= 3\n | mohitsatija | NORMAL | 2022-10-18T19:16:59.079059+00:00 | 2022-10-18T19:16:59.079100+00:00 | 51 | false | ```\nSELECT actor_id,director_id FROM ActorDirector \nGROUP BY actor_id,director_id \nhaving count(*) >= 3\n``` | 1 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | MySQL solution in 4 lines | mysql-solution-in-4-lines-by-shubhamyada-2aar | \nselect actor_id, director_id\nfrom actordirector\ngroup by actor_id, director_id\nhaving count(1)>= 3\n | shubhamyadav32100 | NORMAL | 2022-10-14T16:25:48.187449+00:00 | 2022-10-14T16:25:48.187478+00:00 | 277 | false | ```\nselect actor_id, director_id\nfrom actordirector\ngroup by actor_id, director_id\nhaving count(1)>= 3\n``` | 1 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Can't be more simple than this one | cant-be-more-simple-than-this-one-by-div-lrag | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \ngrup by and count\n\n# | Diving_in_Ocean | NORMAL | 2022-10-01T18:43:54.288709+00:00 | 2022-10-01T18:43:54.288749+00:00 | 162 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\ngrup by and count\n\n# Code\n```\n# Write your MySQL query statement below\n\nselect actor_id,director_id from (select actor_id , director_id , count(director_id) as tt from ActorDirector group by actor_id,director_id) t where t.tt>=3;\n``` | 1 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | GROUP BY HAVING | group-by-having-by-kajal_shukla124-cd35 | SELECT actor_id,director_id FROM ActorDirector\nGROUP BY actor_id,director_id HAVING count(timestamp)>2; | kajal_shukla124 | NORMAL | 2022-09-25T07:28:41.181319+00:00 | 2022-09-25T07:28:41.181353+00:00 | 52 | false | SELECT actor_id,director_id FROM ActorDirector\nGROUP BY actor_id,director_id HAVING count(timestamp)>2; | 1 | 0 | [] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | mysql soln | mysql-soln-by-quater_nion-xlbo | \nselect actor_id, director_id from ActorDirector\ngroup by actor_id, director_id \nhaving count(actor_id)>=3\n | quater_nion | NORMAL | 2022-09-16T15:46:11.068570+00:00 | 2022-09-16T15:46:11.068616+00:00 | 262 | false | ```\nselect actor_id, director_id from ActorDirector\ngroup by actor_id, director_id \nhaving count(actor_id)>=3\n``` | 1 | 0 | [] | 1 |
actors-and-directors-who-cooperated-at-least-three-times | Actors and Directors who cooperated at least three times. Efficient solution | actors-and-directors-who-cooperated-at-l-ejks | select actor_id,director_id from ActorDirector group by actor_id,director_id\nhaving count(*)>=3; | Vinay_Ghildiyal | NORMAL | 2022-09-11T07:15:08.683728+00:00 | 2022-09-11T07:15:08.683761+00:00 | 174 | false | select actor_id,director_id from ActorDirector group by actor_id,director_id\nhaving count(*)>=3; | 1 | 0 | [] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | easy mysql solution | easy-mysql-solution-by-invincible2511-nmsa | \nselect distinct actor_id, director_id from ActorDirector \ngroup by actor_id, director_id\nhaving count(*)>2\n | Invincible2511 | NORMAL | 2022-09-09T13:57:25.790842+00:00 | 2022-09-09T13:57:25.790884+00:00 | 148 | false | ```\nselect distinct actor_id, director_id from ActorDirector \ngroup by actor_id, director_id\nhaving count(*)>2\n``` | 1 | 0 | [] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Easy | easy-by-naomi_tqf-gnrz | select actor_id, director_id from ActorDirector \ngroup by actor_id, director_id\nhaving count(*) > 2 | Naomi_TQF | NORMAL | 2022-09-04T03:41:02.719187+00:00 | 2022-09-04T03:41:02.719210+00:00 | 76 | false | select actor_id, director_id from ActorDirector \ngroup by actor_id, director_id\nhaving count(*) > 2 | 1 | 0 | [] | 1 |
actors-and-directors-who-cooperated-at-least-three-times | MySQL solution using [HAVING] | Easy Step-by-Step Explanation | mysql-solution-using-having-easy-step-by-vks1 | \n# Write your MySQL query statement below\nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(director_id)>=3;\n\n\ | MohammedHamza | NORMAL | 2022-09-01T18:07:09.533179+00:00 | 2022-09-01T18:07:37.334226+00:00 | 86 | false | ```\n# Write your MySQL query statement below\nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(director_id)>=3;\n```\n\n**Explanation:**\n```\nSELECT actor_id, director_id\nFROM ActorDirector\n```\n* First I have selected **actor_id and director_id**.\n\n```\nGROUP BY actor_id, director_id\n```\n* Then I have **GROUP BY** them by **actor_id and director_id** as we need both to fulfill the condition.\n\n```\nHAVING COUNT(director_id)>=3;\n```\n* I have used **HAVING** clause on **COUNT** of **director_id**.\n* If it is greater than equal to 3 than filter out the result.\n* You can also use **actor_id**. | 1 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | SQL! 📸📸 | sql-by-sc0d3r-jhcn | \nselect actor_id,\ndirector_id\nfrom ActorDirector\ngroup by actor_id,director_id\nhaving count(*) >= 3\n | SC0d3r | NORMAL | 2022-08-30T12:36:22.903419+00:00 | 2022-08-30T12:36:22.903483+00:00 | 52 | false | ```\nselect actor_id,\ndirector_id\nfrom ActorDirector\ngroup by actor_id,director_id\nhaving count(*) >= 3\n``` | 1 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | MYSQL SOLUTION | GROUPBY && HAVING STATMENT | EASY UNDERSTANDING | mysql-solution-groupby-having-statment-e-d83g | \nSELECT a.actor_id , a.director_id \nFROM ActorDirector a\nGROUP BY a.actor_id , a.director_id \nHAVING COUNT(*) >= 3\n\n\n### kindly vote up if it usefull | gom3a98 | NORMAL | 2022-08-25T09:39:33.716397+00:00 | 2022-08-25T09:39:33.716438+00:00 | 136 | false | ```\nSELECT a.actor_id , a.director_id \nFROM ActorDirector a\nGROUP BY a.actor_id , a.director_id \nHAVING COUNT(*) >= 3\n```\n\n### **kindly vote up if it usefull** | 1 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Faster than 72.91% | MySQL Solution | Easy to Understand | faster-than-7291-mysql-solution-easy-to-blc2k | ```\nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(*)>=3; | arghapaul002 | NORMAL | 2022-08-21T00:58:43.158909+00:00 | 2022-08-21T00:58:43.158956+00:00 | 131 | false | ```\nSELECT actor_id, director_id\nFROM ActorDirector\nGROUP BY actor_id, director_id\nHAVING COUNT(*)>=3; | 1 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | mysql faster solution | mysql-faster-solution-by-anshika_soni-et8w | ```# Write your MySQL query statement below\nselect actor_id,director_id from ActorDirector group by actor_id,director_id having count(*)>=3 | anshika_soni | NORMAL | 2022-08-14T14:24:55.597240+00:00 | 2022-08-14T14:24:55.597267+00:00 | 107 | false | ```# Write your MySQL query statement below\nselect actor_id,director_id from ActorDirector group by actor_id,director_id having count(*)>=3 | 1 | 0 | ['MySQL'] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Faster than 97% of solutions with CONCAT, GROUP BY and HAVING | faster-than-97-of-solutions-with-concat-hwhwo | select A.actor_id , A.director_id\nfrom ActorDirector A\nGROUP BY CONCAT(A.actor_id ,"_", A.director_id)\nHAVING COUNT(*) >= 3 | sourabh_python | NORMAL | 2022-08-13T12:57:54.821440+00:00 | 2022-08-13T12:57:54.821486+00:00 | 61 | false | select A.actor_id , A.director_id\nfrom ActorDirector A\nGROUP BY CONCAT(A.actor_id ,"_", A.director_id)\nHAVING COUNT(*) >= 3 | 1 | 0 | [] | 0 |
actors-and-directors-who-cooperated-at-least-three-times | Simple Solution faster than 98.77% | simple-solution-faster-than-9877-by-user-g4eh | \n/* Write your T-SQL query statement below */\n\nselect actor_id , director_id FROM ActorDirector \nGROUP BY actor_id , director_id\nHAVING COUNT(*) > 2\n | user6736jw | NORMAL | 2022-08-07T09:37:25.253221+00:00 | 2022-08-07T09:37:45.564346+00:00 | 100 | false | ```\n/* Write your T-SQL query statement below */\n\nselect actor_id , director_id FROM ActorDirector \nGROUP BY actor_id , director_id\nHAVING COUNT(*) > 2\n``` | 1 | 0 | [] | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.