Lädt...

🔧 SQL Problem 1 — Matching Skills — Easy Solution


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

Running notes

Tables we have -

candidate | skill

Question

  1. find candidates proficient in Python, Tableau, and PostgreSQL (ALL 3 SKILLS)
  2. Sort the output by candidate ID in ascending order

Solution

SELECT * 
FROM candidates;

This has given me an overall view of the database, so i know how the dataset looks like

SELECT * 
FROM candidates
WHERE skill IN ('Python','Tableau','PostgreSQL');

This is now showing me all the candidates that have any one of these skills

💡

WHERE clause outputs the rows where a certain condition is met

💡

IN clause

  • used to filter categorical data
  • instead of a more tedious approach of multiple ORs we can directly use an IN clause
  • so here it is checking if anything from the ‘skill’ column is matching to either - Python, Tableau or PostgreSQL and if any of the value is matched that row is shown in the output

Now the question further says that I need to find those candidate_id’s who have all the 3 skills

SELECT candidate_id, COUNT(skill) as number_of_skills_out_of_3_required_skills
FROM candidates
WHERE skill IN ('Python','Tableau','PostgreSQL')
GROUP BY candidate_id;

So in order to group by the candidates and count the number of skills they have from the 3 required skills

💡

GROUP BY clause tells the database to separate the data in different groups so we can perform aggregation on these groups separately (like how I need to perform an aggregation on the number of skills to see if they have all the 3 required skills)

💡

COUNT counts how many rows we have in a particular column

so this is how my output looks like so now I know candidate 123 has all the 3 required skills but candidate 345 has only 2 required skills

so my output should only show candidate_id 123

SELECT candidate_id, COUNT(skill) as number_of_skills_out_of_3_required_skills
FROM candidates
WHERE skill IN ('Python','Tableau','PostgreSQL')
GROUP BY candidate_id
WHERE COUNT(skill) = 3;

So a general thought would lead us to using a WHERE clause (WHERE clause outputs only a certain rows where the condition is satisfied)

This code will give an error because aggregate functions are not allowed in WHERE clause

💡

WHERE clause is used to filter data before aggregation

💡

To filter data based on an aggregate function result, we must use the HAVING clause.

So, drumrolls for the final query

SELECT candidate_id
FROM candidates
WHERE skill IN ('Python','Tableau','PostgreSQL')
GROUP BY candidate_id
HAVING COUNT(skill) = 3
ORDER BY candidate_id;

Written By,

Harshee Pitroda

...

🔧 SQL Problem 1 — Matching Skills — Easy Solution


📈 46.36 Punkte
🔧 Programmierung

🔧 SQL Problem 1 — Matching Skills — Easy Solution


📈 46.36 Punkte
🔧 Programmierung

🔧 C# Pattern Matching Inside Out: Kompakter und prägnanter C#-Code durch Pattern Matching


📈 28.38 Punkte
🔧 Programmierung

🔧 Advanced Scheduling Patterns with Demand-Based Matching, Skills, and Competencies. Part 4.


📈 22.45 Punkte
🔧 Programmierung

📰 StereoAnything: A Highly Practical AI Solution for Robust Stereo Matching


📈 21.86 Punkte
🔧 AI Nachrichten

📰 StereoAnything: A Highly Practical AI Solution for Robust Stereo Matching


📈 21.86 Punkte
🔧 AI Nachrichten

🕵️ Ether Easy Converter/Easy Creator/Easy Burner 1.4.24 memory corruption


📈 20.88 Punkte
🕵️ Sicherheitslücken

🕵️ Ether Easy Converter/Easy Creator/Easy Burner 1.4.24 Pufferüberlauf


📈 20.88 Punkte
🕵️ Sicherheitslücken

🔧 Two sum problem solution in easy way [Day-03]


📈 20.72 Punkte
🔧 Programmierung

🔧 Help me to solve the AI data-matching problem


📈 20.28 Punkte
🔧 Programmierung

📰 Dating app boss sees ‘no problem’ on face-matching without consent


📈 20.28 Punkte
📰 IT Security Nachrichten

🔧 Search for the closest matching record within the group:From SQL to SPL


📈 17.38 Punkte
🔧 Programmierung

🔧 Find What You Need: Pattern Matching in SQL


📈 17.38 Punkte
🔧 Programmierung

🔧 Beyond Technical Skills; Soft Skills...


📈 16.51 Punkte
🔧 Programmierung

🔧 Hard Skills e Soft Skills o que são?


📈 16.51 Punkte
🔧 Programmierung

📰 Premium Alexa Skills: Geld verdienen mit Alexa-Skills


📈 16.51 Punkte
📰 IT Nachrichten

📰 AI skills or AI-enhanced skills? What employers need could depend on you


📈 16.51 Punkte
📰 IT Nachrichten

📰 Premium Alexa Skills: Skills für Amazons Alexa mit Bezahlfunktion starten


📈 16.51 Punkte
📰 IT Nachrichten

📰 More skills are needed to help AI plug skills gaps


📈 16.51 Punkte
📰 IT Nachrichten

📰 Workday Debuts a Universal Skills Ontology Called Skills Cloud


📈 16.51 Punkte
📰 IT Nachrichten

📰 What are The Must Have Skills for Automation Engineers? Top 5 Skills | UpGuard


📈 16.51 Punkte
📰 IT Security Nachrichten

📰 Survey: 81% of Infosec Pros Say Required Job Skills Have Changed amid Skills Gap


📈 16.51 Punkte
📰 IT Security Nachrichten

🔧 How To Find A Job With Soft Skills When Coding Skills Are Weak VI


📈 16.51 Punkte
🔧 Programmierung

🔧 How To Find A Job With Soft Skills When Coding Skills Are Weak III


📈 16.51 Punkte
🔧 Programmierung

🔧 How To Find A Job With Soft Skills When Coding Skills Are Weak I


📈 16.51 Punkte
🔧 Programmierung

📰 To alleviate DevOps skills issues, we need more AI skills, ironically


📈 16.51 Punkte
📰 IT Nachrichten

📰 Hard Skills Vs Soft Skills: How Much Does Software Affect A Developer’s Career?


📈 16.51 Punkte
📰 IT Security Nachrichten

🔧 Why "Soft Skills" Are the Hardest (and Most Rewarding) Skills to Master 🎯


📈 16.51 Punkte
🔧 Programmierung

📰 Hot Skills: Welche Skills Arbeitgeber von Freiberuflern in Corona-Zeiten erwarten


📈 16.51 Punkte
📰 IT Nachrichten

matomo