Skip to content

Commit 61f161a

Browse files
authored
Update README.md
1 parent f90cbe4 commit 61f161a

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

README.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,39 @@ SQL, Structured Query Language, is a programming language designed to manage dat
77

88
### 1.Query for Retrieving Tables
99
> This query can be run to retrieve the list of tables present in a database where the database is “My_Schema”.
10+
1011
`SELECT * FROM My_Schema.Tables;`
1112

1213
### 2. Query for Selecting Columns from a Table
1314
> This is perhaps the most widely used SQL query. In the example below, we are extracting the “Student_ID” column or attribute from the table “STUDENT”.
15+
1416
`SELECT Student_ID FROM STUDENT;`
1517

1618
> If you want to display all the attributes from a particular table, this is the right query to use:
19+
1720
`SELECT * FROM STUDENT;`
1821

1922
### 3.Query for Outputting Data Using a Constraint
2023
> This query retrieves the specified attributes from the table on the constraint Employee ID =0000
24+
2125
`SELECT EMP_ID, NAME FROM EMPLOYEE_TBL WHERE EMP_ID = '0000';`
2226

2327
### 4.Query for Outputting Sorted Data Using ‘Order By’
2428
> This query orders the results with respect to the attribute which is referenced to using “Order By” – so for example, if that attribute is an integer data type, then the result would either be sorted in ascending or descending order; likewise, if the data type is a String then the result would be ordered in alphabetical order.
29+
2530
`SELECT EMP_ID, LAST_NAME FROM EMPLOYEE
31+
2632
WHERE CITY = 'Seattle' ORDER BY EMP_ID;`
2733

2834
> The ordering of the result can also be set manually, using “asc ” for ascending and “desc” for descending.
35+
2936
`SELECT EMP_ID, LAST_NAME FROM EMPLOYEE_TBL
37+
3038
WHERE CITY = 'INDIANAPOLIS' ORDER BY EMP_ID asc;`
3139

3240
### 5.Query for Outputting Sorted Data Using ‘Group By’
3341
> The ‘Group By’ property groups the resulting data according to the specified attribute.
42+
3443
`SELECT Name, Age FROM Patients WHERE Age > 40
3544
GROUP BY Age ORDER BY Name;`
3645

@@ -43,40 +52,48 @@ GROUP BY Age ORDER BY Name;`
4352

4453
### 6.Data Manipulation Using COUNT
4554
> This query displays the total number of customers by counting each customer ID. In addition, it groups the results according to the country of each customer.
55+
4656
`SELECT COUNT(CustomerID), Country FROM Customers GROUP BY Country;`
4757

4858
### 7. Data Manipulation Using SUM
4959
> SUM calculates the total of the attribute that is given to it as an argument.
60+
5061
`SELECT SUM(Salary)FROM Employee WHERE Emp_Age < 30;`
5162

5263
### 8. Data Manipulation Using AVG
5364
Simple – an average of a given attribute.
65+
5466
`SELECT AVG(Price)FROM Products;`
5567

5668
### 9. ALTER TABLE
5769
> ALTER TABLE lets you add columns to a table in a database.
70+
5871
`ALTER TABLE table_name
5972
ADD column_name datatype;`
6073

6174
### 10. AND
6275
> AND is an operator that combines two conditions. Both conditions must be true for the row to be included in the result set.
76+
6377
`SELECT column_name(s)
6478
FROM table_name
6579
WHERE column_1 = value_1
6680
AND column_2 = value_2;`
6781

6882
### 11. AS
6983
> AS is a keyword in SQL that allows you to rename a column or table using an alias.
84+
7085
`SELECT column_name AS 'Alias'
7186
FROM table_name;`
7287

7388
### 12. AVG
7489
> AVG() is an aggregate function that returns the average value for a numeric column.
90+
7591
`SELECT AVG(column_name)
7692
FROM table_name;`
7793

7894
### 13. BETWEEN
7995
> The BETWEEN operator is used to filter the result set within a certain range. The values can be numbers, text or dates.
96+
8097
`SELECT column_name(s)
8198
FROM table_name
8299
WHERE column_name BETWEEN value_1 AND value_2;`
@@ -104,7 +121,7 @@ WHERE GPA > 40;`
104121
> This query updates the view named ‘Product List’ – and if this view doesn’t exist, then the Product List view gets created as specified in this query.
105122
106123
`CREATE OR REPLACE VIEW [ Product List] AS
107-
SELECT ProductID, ProductName, Category
108-
FROM Products
109-
WHERE Discontinued = No;`
124+
SELECT ProductID, ProductName, Category
125+
FROM Products
126+
WHERE Discontinued = No;`
110127

0 commit comments

Comments
 (0)