Day 19/90 — SQL Series | Week 3: Functions "Find all customers whose name starts with R." "Find all emails from Gmail." "Find all products with 'shirt' somewhere in the name." All 3 solved with LIKE + wildcards. % → any number of characters (zero or more) _ → exactly one character WHERE name LIKE 'R%' → starts with R (Rahul, Rohan, Riya) WHERE email LIKE '%@gmail.com' → ends with @gmail.com WHERE product LIKE '%shirt%' → 'shirt' anywhere in the name WHERE code LIKE 'A_01' → A then any 1 char then 01 (e.g. AB01, AC01) LIKE is case-insensitive in SQL Server by default. Combine with NOT LIKE to exclude patterns. #SQL #LIKEOperator #DataAnalytics #LearnSQL #DataAnalyst
SQL LIKE Operator: Filtering with Wildcards
More Relevant Posts
-
🚀 Day 40/100 – LeetCode SQL Challenge Today I solved 1141. User Activity for the Past 30 Days I 💻 🔍 Problem Summary Given a user activity table, the goal was to find the number of daily active users in the last 30 days ending on 2019-07-27. 🧠 What I Learned Today • Importance of date filtering using BETWEEN • Using COUNT(DISTINCT column) to avoid duplicate counting • Proper use of GROUP BY for aggregation • Understanding how multiple activities in a day still count as one active user ⚙️ My Approach Identified the correct date range → 2019-06-28 to 2019-07-27 Filtered data using WHERE Grouped records by activity_date Counted unique users using COUNT(DISTINCT user_id) ✅ Final Query SELECT activity_date AS day, COUNT(DISTINCT user_id) AS active_users FROM Activity WHERE activity_date BETWEEN '2019-06-28' AND '2019-07-27' GROUP BY activity_date; 🎯 Key Insight 👉 Even if a user performs multiple actions in a day, they are counted only once per day. Consistency is the key 🔑 #Day40 #LeetCode #SQL #DataStructures #CodingJourney #PlacementPreparation #LearningEveryday
To view or add a comment, sign in
-
-
When you write SQL, you write it in one order, but the database engine reads it in another. Understanding this is the "secret sauce" to debugging queries. How you write it: SELECT → FROM → WHERE → GROUP BY → HAVING → ORDER BY How the Computer thinks: FROM / JOIN: Where is the data coming from? WHERE: Filter the raw rows. GROUP BY: Bundle them up. HAVING: Filter the bundled groups. SELECT: Pick the columns to show. ORDER BY: Sort the final results. #follow #linkdin #post #sql.
To view or add a comment, sign in
-
Scared of SQL? I recommend you to check just these 25 Commands: 1. SELECT 2. LIMIT 3. AS 4. SELECT DISTINCT 5. COUNT 6. MIN 7. MAX 8. SUM 9. AVERAGE 10. WHERE 11. HAVING 12. AND 13. OR 14. BETWEEN 15. IN 16. LIKE 17. GROUP BY 18. ORDER BY 19. UPDATE 20. ALTER TABLE 22. INSERT INTO 23. INNER JOIN 24. LEFT JOIN 25. RIGHT JOIN #sql #tips #juniordataanalyst #internanalyst #databaseanalyst
To view or add a comment, sign in
-
Nobody told me SQL queries could get this long. As a beginner, I expected short and simple. What I got was multi-layered CTEs, window functions, and logic that builds on itself step by step. Honestly? That complexity is what makes it powerful. #LearningInPublic #AspiringDataAnalyst #SQL #CareerChange #DataAnalytics
To view or add a comment, sign in
-
Got to know a new irrelevant thing while doing a SQL Injection: Ever trusted your COUNT(*) and got burned later? Here’s the catch: COUNT(*) counts everything including rows where your important column might be NULL. But COUNT(column_name)? That only counts non-null values. For Eg: SELECT COUNT(*) AS total_rows, COUNT(email) AS emails_present FROM user_detail; Can quietly expose how much of your data is actually missing. #SQL #Functions #LearningSteps #MySQL
To view or add a comment, sign in
-
📅 Day 47/100 – LeetCode SQL Practice 🧩 Problem: 180. Consecutive Numbers 📖 Problem Description: Given a table Logs with columns id and num, where id is auto-incremented, we need to find all numbers that appear at least three times consecutively. The result should return unique numbers that satisfy this condition. 💡 What I Learned Today: How to detect consecutive records using id Using self joins to compare multiple rows from the same table Why DISTINCT is important to remove duplicate results Understanding overlapping sequences in SQL 🔍 My Approach: Used the same table 3 times (l1, l2, l3) Matched rows where: IDs are consecutive (id, id+1, id+2) Values are equal Used DISTINCT to ensure unique output 💻 SQL Solution: SELECT DISTINCT l1.num AS ConsecutiveNums FROM logs l1 JOIN logs l2 ON l1.id = l2.id - 1 JOIN logs l3 ON l1.id = l3.id - 2 WHERE l1.num = l2.num AND l2.num = l3.num; 🎯 Key Insight: 👉 “Self join + consecutive ID check + same values + DISTINCT = solution” 🔥 Consistency is the key. One step closer to mastering SQL! #Day47 #100DaysOfCode #LeetCode #SQLPractice #CodingJourney #DataStructures #ProblemSolving #Consistency #TechSkills #PlacementPreparation
To view or add a comment, sign in
-
-
Day 26/90 — SQL Series | Week 4 "My WHERE clause is not filtering dates correctly." "My SUM is returning NULL instead of a number." 9 times out of 10 — it's a data type mismatch. CAST and CONVERT fix it. CAST('250' AS INT) → turns text into number so you can do math CAST('2024-01-15' AS DATE) → turns text into date so filters work CAST(order_id AS VARCHAR) → turns number into text for concatenation Rule: use CAST (works everywhere). Use CONVERT only when you need date formatting in SQL Server. #SQL #CastConvert #DataAnalytics #LearnSQL #DataAnalyst
To view or add a comment, sign in
-
-
DAY-256 OF SQL =========== RANKING FUNCTION/WINDOW FUNCTION: In SQL, ranking functions are window functions that assign a rank to each row based on a specified order. Common ones are ROW_NUMBER() (unique sequential numbers), RANK() (same rank for ties, skips next ranks), and DENSE_RANK() (same rank for ties, no skips). Using the OVER() clause, you can rank rows within partitions or the whole dataset, useful for top performers, pagination, or finding duplicates.
To view or add a comment, sign in
-
🧩 SQL Practice: Finding User Purchases Solved a good SQL problem from StrataScratch: 👉 Find users who made a second purchase within 1–7 days of their first purchase (excluding same-day purchases). 💡 Approach: Get each user’s first purchase date Join it back with all transactions Calculate the day difference Filter users who returned within 1–7 days 📌 Concepts used: CTE (WITH) | Aggregation (MIN) | Joins | Date arithmetic 🔗 Problem link: https://lnkd.in/g9EyimWx Simple problem, but a good way to practice real-world SQL logic. #SQL #DataAnalytics #Practice
To view or add a comment, sign in
-
-
I was working on a simple query and thought this would work 👇 ALTER TABLE programmer MODIFY COLUMN email AFTER id; But… ❌ it threw an error. After digging a bit, I realized something important 👇 👉 In SQL (especially MySQL), when you use MODIFY COLUMN, you must redefine the column completely — including its data type. ✅ Correct way: ALTER TABLE programmer MODIFY COLUMN email VARCHAR(255) AFTER id; If you're learning SQL, remember: 👉 Always specify the data type when modifying columns 👉 Don’t ignore small errors — they often teach big lessons Have you faced something similar while learning? 👇 #SQL #Database #LearningInPublic #DeveloperJourney #TechLearning #BuildInPublic #CodingTips
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