"if you encounter any errors in SAP, send me a screenshot at pramod@learntosap.com, and I will help you resolve the issue."

SQL Aliases Explained with Example alias in sql query

SQL TUTORIALS-

SQL Aliases Explained with Example alias in sql query

Introduction-


Trulli Trulli

βœ…What is an Alias in SQL?

-βœ…SQL Aliases are used to rename columns or tables temporarily in a query for better readability. is use In SQL, an alias is an alternative name used to temporarily rename a column or a table in a query. Aliases make your SQL statements more readable, cleaner, and easier to understand (example)-alies created and use AS keyword, although using AS is optional in many databases example- MySQL, PostgreSQL, or SQL Server.


Emoji Examples in HTML

πŸ”Έ Example Table: Employee


ID Name SALARY DEPARTMENT
1 ANNI 20000 IT
2 SUJAN 25000 HR
3 BOULT 30000 FINANCE
4 POOJA 35000 SALES

βœ… Example 1: Column Alias-



SELECT emp_name AS Name, salary AS "Monthly Salary"
FROM employee;

βœ…Result Show :-

Result β†’ ANNI | 20000 | SUJAN | 25000 | BOULT | 30000 | POOJA | 35000


πŸ’‘ Note: The SQL Aliases operator. An alias in SQL is a temporary name given to a column or table to make queries shorter, clearer, or more readable. .

βœ… Example 2: Alias with Expression (Calculating Annual Salary)-



SELECT name, salary * 12 AS "Annual Salary"
FROM employee;

βœ…Result Show :-

Result β†’ ANNI | 240000 | SUJAN | 300000 | BOULT | 360000 | POOJA | 420000


βœ… Example 3: Alias Without AS Keyword-



SELECT name Name, department Dept
FROM employee;


βœ…Result Show :-

Result β†’ use an alias without the AS keyword, though it's optional and sometimes discouraged for clarity it.


βœ… 4. Table Alias in JOIN-



SELECT e.emp_name, d.dept_location
FROM employee e
JOIN department d ON e.department = d.dept_name;

βœ…Result Show :-

Result β†’ e and d are aliases for employee and department tables.


Practice - Yes/No Quiz

1.Can you use SQL aliases without the AS keyword?

2.Is it valid to use an alias in the WHERE clause like this?


May Be Like Important Link-

-How To Import Data(LSMW) LEGACY SYSTEM MIGRATION WORKBENCH

-Define Condition Type-OBYZ

-Genral Ledger Chart Of Accounts-OBD4

-Document 90039783 saved (no accounting document generated)