TGViewer
Channel Public Channel
SQL Programming Resources

SQL Programming Resources

@sqlanalyst

Find top SQL resources from global universities, cool projects, and learning materials for data analytics.

Admin: @coderfun

Useful links: heylink.me/DataAnalytics

Promotions: @love_data
Subscribers
76.7K
Photos
597
Videos
1
Links
567

Showing posts older than #2074 ยท Back to latest

Older Posts 11 shown
Post #2072 3.85K
1. Does SQL support programming language features?
It is true that SQL is a language, but it does not support programming as it is not a programming language, it is a command language. We do not have some programming concepts in SQL like for loops or while loop, we only have commands which we can use to query, update, delete, etc. data in the database. SQL allows us to manipulate data in a database.

2. What is a trigger?
Trigger is a statement that a system executes automatically when there is any modification to the database. In a trigger, we first specify when the trigger is to be executed and then the action to be performed when the trigger executes. Triggers are used to specify certain integrity constraints and referential constraints that cannot be specified using the constraint mechanism of SQL.

3. What are aggregate and scalar functions?
For doing operations on data SQL has many built-in functions, they are categorized into two categories and further sub-categorized into seven different functions under each category. The categories are:
Aggregate functions:
These functions are used to do operations from the values of the column and a single value is returned.
Scalar functions:
These functions are based on user input, these too return a single value.

4. Define SQL Order by the statement?
The ORDER BY statement in SQL is used to sort the fetched data in either ascending or descending according to one or more columns.
By default ORDER BY sorts the data in ascending order.
We can use the keyword DESC to sort the data in descending order and the keyword ASC to sort in ascending order.

5. What is the difference between primary key and unique constraints? 
The primary key cannot have NULL values, the unique constraints can have NULL values. There is only one primary key in a table, but there can be multiple unique constraints. The primary key creates the clustered index automatically but the unique key does not.
  • โค 6
  • ๐Ÿ‘ 1
Post #2071 4.25K
Preparing for a SQL interview?

Focus on mastering these essential topics:

1. Joins: Get comfortable with inner, left, right, and outer joins.
Knowing when to use what kind of join is important!

2. Window Functions: Understand when to use
ROW_NUMBER, RANK(), DENSE_RANK(), LAG, and LEAD for complex analytical queries.

3. Query Execution Order: Know the sequence from FROM to
ORDER BY. This is crucial for writing efficient, error-free queries.

4. Common Table Expressions (CTEs): Use CTEs to simplify and structure complex queries for better readability.

5. Aggregations & Window Functions: Combine aggregate functions with window functions for in-depth data analysis.

6. Subqueries: Learn how to use subqueries effectively within main SQL statements for complex data manipulations.

7. Handling NULLs: Be adept at managing NULL values to ensure accurate data processing and avoid potential pitfalls.

8. Indexing: Understand how proper indexing can significantly boost query performance.

9. GROUP BY & HAVING: Master grouping data and filtering groups with HAVING to refine your query results.

10. String Manipulation Functions: Get familiar with string functions like CONCAT, SUBSTRING, and REPLACE to handle text data efficiently.

11. Set Operations: Know how to use UNION, INTERSECT, and EXCEPT to combine or compare result sets.

12. Optimizing Queries: Learn techniques to optimize your queries for performance, especially with large datasets.

Here you can find essential SQL Interview Resources๐Ÿ‘‡
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v

Like this post if you need more ๐Ÿ‘โค๏ธ

Hope it helps :)
  • โค 3
Post #2060 4K
Advanced SQL Concepts ๐Ÿ’ฅ๐Ÿ“Œ
  • ๐Ÿ‘ 4
  • โค 2
Post #2059 3.34K
Getting started with SQL comparison operators.

If you're new to SQL, understanding comparison operators is one of the first things you'll need to learn.

Theyโ€™re really important for filtering and analyzing your data. Letโ€™s break them down with some simple examples.

Comparison operators let you compare values in SQL queries. Here are the basics:
1. = (Equal To): Checks if two values are the same.
Example: SELECT * FROM Employees WHERE Age = 30; (This will find all employees who are exactly 30 years old).

2. <> or != (Not Equal To): Checks if two values are different.
Example: SELECT * FROM Employees WHERE Age <> 30; (This will find all employees who are not 30 years old).

3. > (Greater Than): Checks if a value is larger.
Example: SELECT * FROM Employees WHERE Salary > 50000; (This will list all employees earning more than 50,000).

4. < (Less Than): Checks if a value is smaller.
Example: SELECT * FROM Employees WHERE Salary < 50000; (This will show all employees earning less than 50,000).

5. >= (Greater Than or Equal To): Checks if a value is larger or equal.
Example: SELECT * FROM Employees WHERE Age >= 25; (This will find all employees who are 25 years old or older).

6. <= (Less Than or Equal To): Checks if a value is smaller or equal.
Example: SELECT * FROM Employees WHERE Age <= 30; (This will find all employees who are 30 years old or younger).

These simple operators can help you get more accurate results in your SQL queries.

Keep practicing and youโ€™ll be great at SQL in no time.

Like this post if you need more ๐Ÿ‘โค๏ธ

Hope it helps :)
  • โค 8
Post #2057 3.05K
SQL interview questions with answers ๐Ÿ˜„๐Ÿ‘‡

1. Question: What is SQL?

Answer: SQL (Structured Query Language) is a programming language designed for managing and manipulating relational databases. It is used to query, insert, update, and delete data in databases.

2. Question: Differentiate between SQL and MySQL.

Answer: SQL is a language for managing relational databases, while MySQL is an open-source relational database management system (RDBMS) that uses SQL as its language.

3. Question: Explain the difference between INNER JOIN and LEFT JOIN.

Answer: INNER JOIN returns rows when there is a match in both tables, while LEFT JOIN returns all rows from the left table and the matched rows from the right table, filling in with NULLs for non-matching rows.

4. Question: How do you remove duplicate records from a table?

Answer: Use the DISTINCT keyword in a SELECT statement to retrieve unique records. For example: SELECT DISTINCT column1, column2 FROM table;

5. Question: What is a subquery in SQL?

Answer: A subquery is a query nested inside another query. It can be used to retrieve data that will be used in the main query as a condition to further restrict the data to be retrieved.

6. Question: Explain the purpose of the GROUP BY clause.

Answer: The GROUP BY clause is used to group rows that have the same values in specified columns into summary rows, like when using aggregate functions such as COUNT, SUM, AVG, etc.

7. Question: How can you add a new record to a table?

Answer: Use the INSERT INTO statement. For example: INSERT INTO table_name (column1, column2) VALUES (value1, value2);

8. Question: What is the purpose of the HAVING clause?

Answer: The HAVING clause is used in combination with the GROUP BY clause to filter the results of aggregate functions based on a specified condition.

9. Question: Explain the concept of normalization in databases.

Answer: Normalization is the process of organizing data in a database to reduce redundancy and improve data integrity. It involves breaking down tables into smaller, related tables.

10. Question: How do you update data in a table in SQL?

Answer: Use the UPDATE statement to modify existing records in a table. For example: UPDATE table_name SET column1 = value1 WHERE condition;

Here is an amazing resources to learn & practice SQL: https://bit.ly/3FxxKPz

Share with credits: https://t.me/sqlspecialist

Hope it helps :)
  • โค 7
Post #2056 3.13K
SQL From Basic to Advanced level

Basic SQL is ONLY 7 commands:
- SELECT
- FROM
- WHERE (also use SQL comparison operators such as =, <=, >=, <> etc.)
- ORDER BY
- Aggregate functions such as SUM, AVERAGE, COUNT etc.
- GROUP BY
- CREATE, INSERT, DELETE, etc.
You can do all this in just one morning.

Once you know these, take the next step and learn commands like:
- LEFT JOIN
- INNER JOIN
- LIKE
- IN
- CASE WHEN
- HAVING (undertstand how it's different from GROUP BY)
- UNION ALL
This should take another day.

Once both basic and intermediate are done, start learning more advanced SQL concepts such as:
- Subqueries (when to use subqueries vs CTE?)
- CTEs (WITH AS)
- Stored Procedures
- Triggers
- Window functions (LEAD, LAG, PARTITION BY, RANK, DENSE RANK)
These can be done in a couple of days.
Learning these concepts is NOT hard at all

- what takes time is practice and knowing what command to use when. How do you master that?
- First, create a basic SQL project
- Then, work on an intermediate SQL project (search online) -

Lastly, create something advanced on SQL with many CTEs, subqueries, stored procedures and triggers etc.

This is ALL you need to become a badass in SQL, and trust me when I say this, it is not rocket science. It's just logic.

Remember that practice is the key here. It will be more clear and perfect with the continous practice

Best telegram channel to learn SQL: https://t.me/sqlanalyst

Data Analyst Jobs๐Ÿ‘‡
https://t.me/jobs_SQL

Join @free4unow_backup for more free resources.

Like this post if it helps ๐Ÿ˜„โค๏ธ

ENJOY LEARNING ๐Ÿ‘๐Ÿ‘
  • โค 9
Post #2054 3.13K
If youโ€™re a Data Analyst, chances are you use ๐’๐๐‹ every single day. And if youโ€™re preparing for interviews, youโ€™ve probably realized that it's not just about writing queries it's about writing smart, efficient, and scalable ones.

1. ๐๐ซ๐ž๐š๐ค ๐ˆ๐ญ ๐ƒ๐จ๐ฐ๐ง ๐ฐ๐ข๐ญ๐ก ๐‚๐“๐„๐ฌ (๐‚๐จ๐ฆ๐ฆ๐จ๐ง ๐“๐š๐›๐ฅ๐ž ๐„๐ฑ๐ฉ๐ซ๐ž๐ฌ๐ฌ๐ข๐จ๐ง๐ฌ)

Ever worked on a query that became an unreadable monster? CTEs let you break that down into logical steps. You can treat them like temporary views โ€” great for simplifying logic and improving collaboration across your team.

2. ๐”๐ฌ๐ž ๐–๐ข๐ง๐๐จ๐ฐ ๐…๐ฎ๐ง๐œ๐ญ๐ข๐จ๐ง๐ฌ

Forget the mess of subqueries. With functions like ROW_NUMBER(), RANK(), LEAD() and LAG(), you can compare rows, rank items, or calculate running totals โ€” all within the same query. Total

3. ๐’๐ฎ๐›๐ช๐ฎ๐ž๐ซ๐ข๐ž๐ฌ (๐๐ž๐ฌ๐ญ๐ž๐ ๐๐ฎ๐ž๐ซ๐ข๐ž๐ฌ)

Yes, they're old school, but nested subqueries are still powerful. Use them when you want to filter based on results of another query or isolate logic step-by-step before joining with the big picture.

4. ๐ˆ๐ง๐๐ž๐ฑ๐ž๐ฌ & ๐๐ฎ๐ž๐ซ๐ฒ ๐Ž๐ฉ๐ญ๐ข๐ฆ๐ข๐ณ๐š๐ญ๐ข๐จ๐ง

Query taking forever? Look at your indexes. Index the columns you use in JOINs, WHERE, and GROUP BY. Even basic knowledge of how the SQL engine reads data can take your skills up a notch.

5. ๐‰๐จ๐ข๐ง๐ฌ ๐ฏ๐ฌ. ๐’๐ฎ๐›๐ช๐ฎ๐ž๐ซ๐ข๐ž๐ฌ

Joins are usually faster and better for combining large datasets. Subqueries, on the other hand, are cleaner when doing one-off filters or smaller operations. Choose wisely based on the context.

6. ๐‚๐€๐’๐„ ๐’๐ญ๐š๐ญ๐ž๐ฆ๐ž๐ง๐ญ๐ฌ:

Want to categorize or bucket data without creating a separate table? Use CASE. Itโ€™s ideal for conditional logic, custom labels, and grouping in a single query.

7. ๐€๐ ๐ ๐ซ๐ž๐ ๐š๐ญ๐ข๐จ๐ง๐ฌ & ๐†๐‘๐Ž๐”๐ ๐๐˜

Most analytics questions start with "how many", "whatโ€™s the average", or "which is the highest?". SUM(), COUNT(), AVG(), etc., and pair them with GROUP BY to drive insights that matter.

8. ๐ƒ๐š๐ญ๐ž๐ฌ ๐€๐ซ๐ž ๐€๐ฅ๐ฐ๐š๐ฒ๐ฌ ๐“๐ซ๐ข๐œ๐ค๐ฒ

Time-based analysis is everywhere: trends, cohorts, seasonality, etc. Get familiar with functions like DATEADD, DATEDIFF, DATE_TRUNC, and DATEPART to work confidently with time series data.

9. ๐’๐ž๐ฅ๐Ÿ-๐‰๐จ๐ข๐ง๐ฌ & ๐‘๐ž๐œ๐ฎ๐ซ๐ฌ๐ข๐ฏ๐ž ๐๐ฎ๐ž๐ซ๐ข๐ž๐ฌ ๐Ÿ๐จ๐ซ ๐‡๐ข๐ž๐ซ๐š๐ซ๐œ๐ก๐ข๐ž๐ฌ

Whether it's org charts or product categories, not all data is flat. Learn how to join a table to itself or use recursive CTEs to navigate parent-child relationships effectively.


You donโ€™t need to memorize 100 functions. You need to understand 10 really well and apply them smartly. These are the concepts I keep going back to not just in interviews, but in the real world where clarity, performance, and logic matter most.
  • โค 10
Post #2052 2.69K
Quick SQL functions cheat sheet for beginners

Aggregate Functions

COUNT(*): Counts rows.

SUM(column): Total sum.

AVG(column): Average value.

MAX(column): Maximum value.

MIN(column): Minimum value.


String Functions

CONCAT(a, b, โ€ฆ): Concatenates strings.

SUBSTRING(s, start, length): Extracts part of a string.

UPPER(s) / LOWER(s): Converts string case.

TRIM(s): Removes leading/trailing spaces.


Date & Time Functions

CURRENT_DATE / CURRENT_TIME / CURRENT_TIMESTAMP: Current date/time.

EXTRACT(unit FROM date): Retrieves a date part (e.g., year, month).

DATE_ADD(date, INTERVAL n unit): Adds an interval to a date.


Numeric Functions

ROUND(num, decimals): Rounds to a specified decimal.

CEIL(num) / FLOOR(num): Rounds up/down.

ABS(num): Absolute value.

MOD(a, b): Returns the remainder.


Control Flow Functions

CASE: Conditional logic.

COALESCE(val1, val2, โ€ฆ): Returns the first non-null value.


Like for more free Cheatsheets โค๏ธ

Share with credits: https://t.me/sqlspecialist

Hope it helps :)

#dataanalytics
  • โค 3
Post #2051 2.95K
Many people ask this common question โ€œCan I get a job with just SQL and Excel?โ€ or โ€œCan I get a job with just Power BI and Python?โ€.

The answer to all of those questions is yes.

There are jobs that use only SQL, Tableau, Power BI, Excel, Python, or R or some combination of those.

However, the combination of tools you learn impacts the total number of jobs you are qualified for.

For example, letโ€™s say with just SQL and Excel you are qualified for 10 jobs, but if you add Tableau to that, you are qualified for 50 jobs.

If you have a success rate of landing a job youโ€™re qualified for of 4%, having 5 times as many jobs to go for greatly improves your odds of landing a job.

Does this mean you should go out there and learn every single skill any data analyst job requires?

NO!

Itโ€™s about finding the core tools that many jobs want.

And, in my opinion, those tools are SQL, Excel, and a visualization tool.

With these three tools, you are qualified for the majority of entry level data jobs and many higher level jobs.

So, you can land a job with whatever tools youโ€™re comfortable with.

But if you have the three tools above in your toolbelt, you will have many more jobs to apply for and greatly improve your chances of snagging one.
  • โค 2
Post #2049 2.71K
SQL Interview Questions for 0-1 year of Experience (Asked in Top Product-Based Companies).

Sharpen your SQL skills with these real interview questions!

Q1. Customer Purchase Patterns -
You have two tables, Customers and Purchases: CREATE TABLE Customers ( customer_id INT PRIMARY KEY, customer_name VARCHAR(255) ); CREATE TABLE Purchases ( purchase_id INT PRIMARY KEY, customer_id INT, product_id INT, purchase_date DATE );
Assume necessary INSERT statements are already executed.
Write an SQL query to find the names of customers who have purchased more than 5 different products within the last month. Order the result by customer_name.

Q2. Call Log Analysis -
Suppose you have a CallLogs table: CREATE TABLE CallLogs ( log_id INT PRIMARY KEY, caller_id INT, receiver_id INT, call_start_time TIMESTAMP, call_end_time TIMESTAMP );
Assume necessary INSERT statements are already executed.
Write a query to find the average call duration per user. Include only users who have made more than 10 calls in total. Order the result by average duration descending.

Q3. Employee Project Allocation - Consider two tables, Employees and Projects:
CREATE TABLE Employees ( employee_id INT PRIMARY KEY, employee_name VARCHAR(255), department VARCHAR(255) ); CREATE TABLE Projects ( project_id INT PRIMARY KEY, lead_employee_id INT, project_name VARCHAR(255), start_date DATE, end_date DATE );
Assume necessary INSERT statements are already executed.
The goal is to write an SQL query to find the names of employees who have led more than 3 projects in the last year. The result should be ordered by the number of projects led.
  • โค 6
Post #2047 2.8K
Older posts โ†’
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’