TGViewer
SQL Programming Resources SQL Programming Resources @sqlanalyst ยท 76.7K subscribers
Post #2708 2.12K
๐Ÿš€ SQL Roadmap 2026 โ€” Part 2

SQL SELECT Statement & Retrieving Data

Now that you understand databases, tables, rows, columns, primary keys, and foreign keys, it's time to learn the most fundamental SQL command: SELECT.

Almost every SQL analysis starts with retrieving data.

1๏ธโƒฃ What is SELECT?

SELECT is used to retrieve data from one or more columns in a table.

Basic syntax:

SELECT column_name
FROM table_name;


Example:

SELECT customer_name
FROM customers;


2๏ธโƒฃ Select Multiple Columns

You can retrieve multiple columns by separating them with commas.

SELECT
customer_id,
customer_name,
city
FROM customers;


Result:

customer_id | customer_name | city

1 | Rahul | Mumbai

2 | Priya | Delhi

3 | Amit | Pune

3๏ธโƒฃ Select All Columns Using *

If you want every column:

SELECT *
FROM customers;


* means all columns.

โš ๏ธ Interview Tip: Although SELECT * is convenient while exploring data, avoid relying on it in production queries. Prefer selecting only needed columns.

4๏ธโƒฃ Column Aliases

Use AS to give a column a different name in the result.

SELECT
customer_name AS name,
city AS location
FROM customers;


The original table is not changed.

5๏ธโƒฃ Aliases Without AS

SELECT
customer_name name,
city location
FROM customers;


However, using AS is generally clearer for beginners.

6๏ธโƒฃ Calculations Inside SELECT

SELECT
product_name,
price,
price * 0.90 AS discounted_price
FROM products;


7๏ธโƒฃ Arithmetic Operators

+ Addition, - Subtraction, * Multiplication, / Division

SELECT
product_name,
selling_price,
cost_price,
selling_price - cost_price AS profit
FROM products;


8๏ธโƒฃ Using Expressions

SELECT
product_name,
quantity,
unit_price,
quantity * unit_price AS total_value
FROM order_items;


9๏ธโƒฃ DISTINCT

Removes duplicate values.

SELECT DISTINCT city
FROM customers;


๐Ÿ”Ÿ DISTINCT Across Multiple Columns

SELECT DISTINCT
city,
customer_segment
FROM customers;


1๏ธโƒฃ1๏ธโƒฃ Using SELECT With Text

SELECT
customer_name,
'Active Customer' AS status
FROM customers;


1๏ธโƒฃ2๏ธโƒฃ Combining Columns

SELECT
first_name,
last_name,
CONCAT(first_name, ' ', last_name) AS full_name
FROM employees;


1๏ธโƒฃ3๏ธโƒฃ SELECT With a Condition

SELECT
customer_name,
city
FROM customers
WHERE city = 'Mumbai';


1๏ธโƒฃ5๏ธโƒฃ SQL Query Structure

At this stage, learn this basic pattern:

SELECT column1, column2
FROM table_name;

SELECT column1, column2
FROM table_name
WHERE condition;


1๏ธโƒฃ6๏ธโƒฃ A Real-World Example

Manager asks: "Show me product name, selling price, cost price, and profit"

SELECT
product_name,
selling_price,
cost_price,
selling_price - cost_price AS profit
FROM products;
  • โค 7
More from @sqlanalyst
  1. Oct 7, 2026๐Ÿš€๐—ฃ๐—ฎ๐˜† ๐—”๐—ณ๐˜๐—ฒ๐—ฟ ๐—ฃ๐—น๐—ฎ๐—ฐ๐—ฒ๐—บ๐—ฒ๐—ป๐˜ ๐—ง๐—ฟ๐—ฎ๐—ถ๐—ป๐—ถ๐—ป๐—ด | ๐—•๐—ฒ๐—ฐ๐—ผ๐—บ๐—ฒ ๐—ฎ ๐—™๐˜‚๐—น๐—น๐˜€๐˜๐—ฎ๐—ฐโ€ฆ
  2. Oct 7, 2026SQL Interview Series โ€” Part 4 ๐Ÿ“Œ Question 4: Find the Highest Salary in Each Department Suโ€ฆ
  3. Oct 7, 2026๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ ๐—•๐—œ ๐—ณ๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜! ๐Ÿ”ฅ Learn Power BI through these FREE learninโ€ฆ
  4. Sep 29, 2026SQL Interview Series โ€” Part 2 ๐Ÿ“Œ Question 2: Find Duplicate Records Suppose you have an Emโ€ฆ
  5. Sep 29, 2026๐—™๐—ฅ๐—˜๐—˜ ๐—ฅ๐—ฒ๐˜€๐—ผ๐˜‚๐—ฟ๐—ฐ๐—ฒ๐˜€ ๐—ง๐—ผ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป ๐—”๐—œ ๐—ถ๐—ป ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ๐Ÿš€ โ€‹ Explore 6 free resourceโ€ฆ
  6. Sep 29, 2026SQL Interview Series โ€” Part 1 Hi guys, let's start a SQL interview series covering frequenโ€ฆ
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 โ†’