Skip to content

Commit 38df862

Browse files
authored
Update README.md
1 parent 791bf88 commit 38df862

File tree

1 file changed

+95
-20
lines changed

1 file changed

+95
-20
lines changed

README.md

Lines changed: 95 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,25 @@ SQL, Structured Query Language, is a programming language designed to manage dat
2727
### 4.Query for Outputting Sorted Data Using ‘Order By’
2828
> 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.
2929
30-
`SELECT EMP_ID, LAST_NAME FROM EMPLOYEE
31-
WHERE CITY = 'Seattle' ORDER BY EMP_ID;`
30+
```
31+
SELECT EMP_ID, LAST_NAME FROM EMPLOYEE
32+
WHERE CITY = 'Seattle' ORDER BY EMP_ID;
33+
```
3234

3335
> The ordering of the result can also be set manually, using “asc ” for ascending and “desc” for descending.
3436
35-
`SELECT EMP_ID, LAST_NAME FROM EMPLOYEE_TBL
36-
WHERE CITY = 'INDIANAPOLIS' ORDER BY EMP_ID asc;`
37+
```
38+
SELECT EMP_ID, LAST_NAME FROM EMPLOYEE_TBL
39+
WHERE CITY = 'INDIANAPOLIS' ORDER BY EMP_ID asc;
40+
```
3741

3842
### 5.Query for Outputting Sorted Data Using ‘Group By’
3943
> The ‘Group By’ property groups the resulting data according to the specified attribute.
4044
41-
`SELECT Name, Age FROM Patients WHERE Age > 40
42-
GROUP BY Age ORDER BY Name;`
43-
44-
45+
```
46+
SELECT Name, Age FROM Patients WHERE Age > 40
47+
GROUP BY Age ORDER BY Name;
48+
```
4549

4650

4751

@@ -68,49 +72,120 @@ Simple – an average of a given attribute.
6872
### 9. ALTER TABLE
6973
> ALTER TABLE lets you add columns to a table in a database.
7074
71-
`ALTER TABLE table_name
72-
ADD column_name datatype;`
75+
```
76+
ALTER TABLE table_name
77+
ADD column_name datatype;
78+
```
7379

7480
### 10. AND
7581
> AND is an operator that combines two conditions. Both conditions must be true for the row to be included in the result set.
7682
77-
`SELECT column_name(s)
83+
```
84+
SELECT column_name(s)
7885
FROM table_name
7986
WHERE column_1 = value_1
80-
AND column_2 = value_2;`
87+
AND column_2 = value_2;
88+
```
8189

8290
### 11. AS
8391
> AS is a keyword in SQL that allows you to rename a column or table using an alias.
8492
85-
`SELECT column_name AS 'Alias'
86-
FROM table_name;`
93+
```
94+
SELECT column_name AS 'Alias'
95+
FROM table_name;
96+
```
8797

8898
### 12. BETWEEN
8999
> The BETWEEN operator is used to filter the result set within a certain range. The values can be numbers, text or dates.
90100
91-
`SELECT column_name(s)
101+
```
102+
SELECT column_name(s)
92103
FROM table_name
93-
WHERE column_name BETWEEN value_1 AND value_2;`
104+
WHERE column_name BETWEEN value_1 AND value_2;
105+
```
94106

95107
### 13. CASE
96108
> CASE statements are used to create different outputs (usually in the SELECT statement). It is SQL's way of handling if-then logic.
97-
`SELECT column_name,
109+
```
110+
SELECT column_name,
98111
CASE
99112
WHEN condition THEN 'Result_1'
100113
WHEN condition THEN 'Result_2'
101114
ELSE 'Result_3'
102115
END
103116
FROM table_name;
104-
`
117+
```
118+
119+
### 14. CREATE TABLE
120+
> CREATE TABLE creates a new table in the database. It allows you to specify the name of the table and the name of each column in the table
121+
```
122+
CREATE TABLE table_name (
123+
column_1 datatype,
124+
column_2 datatype,
125+
column_3 datatype
126+
);
127+
```
128+
129+
### 15. DELETE
130+
> DELETE statements are used to remove rows from a table.
131+
```
132+
DELETE FROM table_name
133+
WHERE some_column = some_value;
134+
```
135+
136+
### 16. HAVING
137+
> HAVING was added to SQL because the WHERE keyword could not be used with aggregate functions.
138+
```
139+
SELECT column_name, COUNT(*)
140+
FROM table_name
141+
GROUP BY column_name
142+
HAVING COUNT(*) > value;
143+
```
144+
145+
### 17. INNER JOIN
146+
> An inner join will combine rows from different tables if the join condition is true.
147+
```
148+
SELECT column_name(s)
149+
FROM table_1
150+
JOIN table_2
151+
ON table_1.column_name = table_2.column_name;
152+
```
153+
154+
### 18. INSERT
155+
> INSERT statements are used to add a new row to a table.
156+
```
157+
INSERT INTO table_name (column_1, column_2, column_3)
158+
VALUES (value_1, 'value_2', value_3);
159+
```
160+
161+
### 19. IS NULL/ IS NOT NULL
162+
> IS NULL and IS NOT NULL are operators used with the WHERE clause to test for empty values.
163+
```
164+
SELECT column_name(s)
165+
FROM table_name
166+
WHERE column_name IS NULL;
167+
```
168+
169+
### 20. LIKE
170+
> LIKE is a special operator used with the WHERE clause to search for a specific pattern in a column.
171+
```
172+
SELECT column_name(s)
173+
FROM table_name
174+
WHERE column_name LIKE pattern;
175+
```
176+
177+
105178

106179

107180
### 9. Query for Creating a View
108181
> A view is a tailored table that is formed as a result of a query. It has tables and rows just like any other table. It’s usually a good idea to run queries as independent views because this allows them to be retrieved later to view the query results, rather than computing the same command every time for a particular set of results.
109182
110-
`CREATE VIEW Failing_Students AS
183+
```
184+
CREATE VIEW Failing_Students AS
111185
SELECT S_NAME, Student_ID
112186
FROM STUDENT
113-
WHERE GPA > 40;`
187+
WHERE GPA > 40;
188+
```
114189

115190
### 10. Query for Listing all Views
116191
> This query lists all the views available in the schema.

0 commit comments

Comments
 (0)