🚀 Day 51 of My SQL Learning Journey Today I solved a SQL problem involving joins and conditional filtering 🔥 🔹 Problem: Find employees whose bonus is less than 1000 or who didn’t receive any bonus 🔗 Problem Link: https://lnkd.in/gF6_J-Vr 🔹 Solution: SELECT e.name, b.bonus FROM Employee e LEFT JOIN Bonus b ON e.empId = b.empId WHERE b.bonus < 1000 OR b.bonus IS NULL; 🔹 Key Learning: Using LEFT JOIN to include unmatched records Handling NULL values properly Applying conditions with multiple filters 💡 Understanding joins is essential for solving real-world database problems! Consistency continues 🚀 #SQL #LeetCode #90DaysOfCode #CodingJourney #ProblemSolving
Pooja Mallelor’s Post
More Relevant Posts
-
SQL Mistake #8: Another SQL mistake from my learning journey 👇 I was solving: “Find the largest number that appears only once. If none exists, return NULL.” ❌ My approach: SELECT num FROM MyNumbers GROUP BY num HAVING COUNT(*) = 1 ORDER BY num DESC LIMIT 1; At first, this felt correct… and in most cases, it works ✅ But there was a hidden edge case ❌ 💥 What went wrong? When no number appears exactly once, this query returns: 👉 empty result (no rows) But the question expects: 👉 NULL ✅ Correct approach: SELECT MAX(num) AS num FROM ( SELECT num FROM MyNumbers GROUP BY num HAVING COUNT(num) = 1 ) t; 🧠 Key learning: GROUP BY + HAVING → filters valid numbers LIMIT → may return no rows ❌ MAX() → always returns one row (even NULL) ✅ Aggregate functions like MAX, MIN return NULL when no data exists 🔥 Real insight: SQL isn’t just about getting the right rows… It’s about handling edge cases correctly Another small mistake, another step forward 🚀 #SQL #DataAnalytics #LearningInPublic #100DaysOfCode #SQLMistakes #LeetCode
To view or add a comment, sign in
-
🚀 Day 50 of My SQL Learning Journey Today I solved a medium-level SQL problem involving user retention analysis 🔥 🔹 Problem: Find the fraction of players who logged in again the day after their first login 🔗 Problem Link: https://lnkd.in/gsSuBeg5 🔹 Solution: SELECT ROUND( COUNT(DISTINCT a.player_id) / (SELECT COUNT(DISTINCT player_id) FROM Activity), 2) AS fraction FROM Activity a JOIN ( SELECT player_id, MIN(event_date) AS first_login FROM Activity GROUP BY player_id ) f ON a.player_id = f.player_id AND a.event_date = DATE_ADD(f.first_login, INTERVAL 1 DAY); 🔹 Key Learning: Using subqueries to find first login Applying date functions (DATE_ADD) Calculating ratios using aggregation Real-world concept: user retention analysis 💡 SQL is powerful for analyzing user behavior and retention patterns! Consistency continues 🚀 #SQL #LeetCode #90DaysOfCode #CodingJourney #DataAnalytics #InterviewPreparation
To view or add a comment, sign in
-
-
🚀 Day 36 of My SQL Learning Journey Today I worked on a challenging SQL problem involving consecutive records and learned an important lesson along the way 🔥 🔹 Problem: Find records where people count is ≥ 100 for at least 3 consecutive entries 🔗 Problem Link: https://lnkd.in/gNBER5CQ 🔹 Final Solution: WITH temp AS ( SELECT id, visit_date, people, id - ROW_NUMBER() OVER (ORDER BY id) AS grp FROM Stadium WHERE people >= 100 ) SELECT id, visit_date, people FROM temp WHERE grp IN ( SELECT grp FROM temp GROUP BY grp HAVING COUNT(*) >= 3 ); 🔹 Key Learning 💡: The approach was to use ID-based grouping, because the problem depends on consecutive entries (IDs), not consecutive dates. 🔹 Concepts Used: ROW_NUMBER() for sequence handling Grouping consecutive records Window functions + aggregation 💡 Debugging mistakes helped me understand the problem more deeply than just solving it! Consistency continues 🚀 #SQL #LeetCode #WindowFunctions #ProblemSolving #90DaysOfCode #CodingJourney
To view or add a comment, sign in
-
-
Hello everyone! 👋 Welcome to Day 2 of #100DaysOfSQL 🚀 👉 Topic: Types of SQL Commands SQL commands are mainly divided into different categories based on their functionality. 👉 1. DDL (Data Definition Language) Used to define and modify database structure. Examples: - CREATE - ALTER - DROP - TRUNCATE 👉 2. DML (Data Manipulation Language) Used to manage data inside tables. Examples: - INSERT - UPDATE - DELETE 👉 3. DQL (Data Query Language) Used to retrieve data from the database. Example: - SELECT 👉 4. DCL (Data Control Language) Used to control access to data. Examples: - GRANT - REVOKE 👉 5. TCL (Transaction Control Language) Used to manage transactions. Examples: - COMMIT - ROLLBACK - SAVEPOINT 👉 Examples: CREATE TABLE students (id INT, name VARCHAR(50)); INSERT INTO students VALUES (1, 'John'); SELECT * FROM students; 👉 Key Takeaway: Understanding SQL command types helps you organize and write efficient queries. #SQL #LearningJourney #DataAnalytics #100DaysOfSQL
To view or add a comment, sign in
-
I’m learning that SQL errors are often not about “complex code” but about small things: query order, punctuation, capitalization, and spelling. What appears to be a logic problem is a missing comma, incorrect keyword placement, or a filter written in the wrong way. The more I practice, the more I see that understanding how SQL thinks makes debugging much easier. Two lessons stood out for me: first, SQL needs structure in the right order, especially knowing where the data is coming from before applying selections and filters. Second, filtering becomes much more powerful when you understand operators like AND, OR, BETWEEN, IN, LIKE, IS NULL, and IS NOT NULL. My biggest takeaway: when debugging SQL, start by checking syntax and query flow first, then review your filtering logic step by step. #SQL #learninginpublic #data
To view or add a comment, sign in
-
🚀 Week 4 of My SQL Learning Journey! This week was packed with deeper insights into SQL and hands-on practice, especially around SQL*Plus and database fundamentals. Here’s what I explored: 🔹 SQL*Plus commands (SET TIMING, FEEDBACK, HEADING, AUTOTRACE, SPOOL, SCRIPT) 🔹 Learned how to record query outputs using SPOOL and execute scripts efficiently 🔹 Explored Pseudo Columns like USER, SYSDATE, ROWNUM, ROWID, NEXTVAL, CURRVAL 🔹 Understood Database Schemas – Tables, Sequences, Synonyms, Indexes, and Views 🔹 Worked on Subqueries (query within a query) and their practical usage 🔹 Revised SQL statement types: DDL, DML, DCL, TCL, and DQL 💡 Key Learning: This week helped me understand how SQL works beyond basic queries — especially how database objects, access control, and system-generated values function internally. 🔐 Also learned user management in databases: ✔ Creating users ✔ Granting & revoking access ✔ Locking/unlocking accounts ✔ Managing passwords 🙏 Grateful for the continuous support and guidance from my mentor Praveen Kalimuthu and the Tech Data Community Consistency and daily practice are helping me build strong confidence step by step 💪 Excited to explore more advanced concepts and real-time scenarios in the coming weeks! #SQL #Database #DataAnalytics #LearningJourney #TechSkills #Consistency #CareerGrowth
To view or add a comment, sign in
-
🚀 Day 32 of My SQL Learning Journey Today I practiced a SQL problem based on JOIN operations 🔹 Problem: Retrieve product name, year, and price for each sale 🔗 Problem Link: https://lnkd.in/gBgY3zhW 🔹 Key Learning: Using JOIN to combine multiple tables Retrieving meaningful data from relational databases Importance of foreign key relationships 💡 JOINs are one of the most important concepts in SQL! Consistency continues 🚀 #SQL #LeetCode #90DaysOfCode #DataAnalytics #CodingJourney
To view or add a comment, sign in
-
-
If you work with data, SQL Joins are something you simply cannot skip. A Join combines rows from two or more tables based on a related column. Most beginners find it confusing — but once you see it visually, it all clicks. There are 4 types you need to know, and each one serves a different purpose. #java#sql#joins#programming#sqlBegineers#learnSql#100daysOfCode
To view or add a comment, sign in
-
-
SQL Progress: Logic & CASE Statements! Today I solved another Medium challenge on LeetCode. This problem was a great lesson in how to calculate percentages and rates directly in SQL. What I learned today: 1. AVG with CASE WHEN: I learned that I can use AVG(CASE WHEN condition THEN 1.0 ELSE 0.0 END) to calculate a rate. It’s a very clear way. 2. Handling NULLs in Rates: By using a LEFT JOIN between the Signups and Confirmations tables, I ensured that users with no actions are still included, and the AVG function automatically treats them as 0 if they don't meet the "confirmed" criteria. 3. Precision with ROUND: Used ROUND(..., 2) to make sure the final confirmation rate is clean and meets the required format(0.00). I would love to learn from your experience: is ther another methods cleaner? قليل مستمر خير من كثير منقطع #SQL #DataEngineering #PostgreSQL #LeetCode #100DaysOfCode #DataAnalytics #ProblemSolving
To view or add a comment, sign in
-
-
**Day 8 of my 30 Days SQL Series 🚀** Today’s question was “Confirmation Rate” from LeetCode. At first, I thought it’s just a simple confirmed / total calculation. But when I actually started solving it, I got stuck in the logic part. --- ### 💡 How I understood the problem: For each user: 👉 how many confirmation requests they received 👉 and out of those, how many they actually confirmed --- ### 😵💫 Where I got stuck: My first instinct was to use: `WHERE action = 'confirmed'` But then I realized: 👉 this would remove all “timeout” rows 👉 and my total count would become wrong That’s when I understood that **sometimes you shouldn’t filter rows, but control the calculation instead** --- ### ⚙️ What I did next: 👉 Used **LEFT JOIN** to make sure even users with no confirmation requests are included (with 0) 👉 Used **CASE WHEN inside COUNT** to count only “confirmed” actions without removing other rows 👉 Used **COUNT(*)** to get total attempts 👉 And finally **IFNULL + ROUND** to handle null values and format the output --- ### 🧠 What I learned today: * Don’t blindly use WHERE — think about what data you might lose * CASE WHEN helps in **conditional counting** * Got a clearer idea of when to use LEFT JOIN --- ### 📊 Simple example: If a user had 2 requests: * 1 confirmed * 1 timeout 👉 rate = 1/2 = 0.5 If a user had no requests at all: 👉 rate = 0 (not NULL) --- Today wasn’t about writing the query fast, it was more about understanding the logic properly. Learning slowly, but it’s making more sense now 💪 #Day8 #SQL #LearningInPublic
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development