-
Notifications
You must be signed in to change notification settings - Fork 1
/
SELECT.sql
176 lines (120 loc) · 5.64 KB
/
SELECT.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
-- SELECT Statement
-- Types of SELECT Syntax
-------------------------------------------------
-------SELECT column_name FROM table_name;-------
--------------------------------------------------
SELECT column_name FROM table_name;
-- SELECT a column from the table employee_info
SELECT Name FROM employee_info;
-- SELECT the column GENE_ID from the table rnaseq
SELECT GENE_ID FROM rnaseq;
-- SELECT the column Gene_Annotation from the table rnaseq
SELECT Gene_Annotation FROM rnaseq;
-- SELECT the column Expression_values from the table rnaseq
SELECT Expression_values FROM rnaseq;
-- SELECT the column Gene_length from the table rnaseq
SELECT Gene_length FROM rnaseq;
-- SELECT the column Unique_gene_reads from the table rnaseq
SELECT Unique_gene_reads FROM rnaseq;
-- SELECT the column Total_gene_read from the table rnaseq
SELECT Total_gene_read FROM rnaseq;
-- SELECT the column RPKM from the table rnaseq
SELECT RPKM FROM rnaseq;
----------------------------------------------------------------
-------SELECT column_name1, column_name2 FROM table_name;-------
----------------------------------------------------------------
-- SELECT multiple columns from a table;
SELECT column_name1, column_name2 FROM table_name;
-- SELECT multiple columns from table employee_info;
SELECT Name, Job FROM employee_info;
-- SELECT columns GENE_ID and RPKM from the table rnaseq
SELECT GENE_ID, RPKM FROM rnaseq;
-- SELECT columns GENE_ID, Gene_Length, RPKM from the table rnaseq
SELECT GENE_ID, Gene_Length, RPKM FROM rnaseq;
-- SELECT columns GENE_ID, Gene_Length,Expression_values and RPKM from the table rnaseq
SELECT GENE_ID, Gene_Length,Expression_values, RPKM FROM rnaseq;
--------------------------------------
--------- SELECT * FROM table;--------
--------------------------------------
-- SELECT All Columns of a table using *
SELECT * FROM table;
-- SELECT all columns from the table employee_info
SELECT * FROM employee_info;
-- SELECT all columns from the table rnaseq using *
SELECT * FROM rnaseq;
---------------------------------------------------------------
--------------SELECT * FROM table_name LIMIT value; -----------
---------------------------------------------------------------
-- SELECT All Columns of a table using * with LIMIT value
SELECT * FROM table_name LIMIT value;
-- SELECT All Columns of the table employee_info using * with LIMIT 3
SELECT * FROM employee_info LIMIT 3;
-- SELECT all columns from the table rnaseq using * with LIMIT 5
SELECT * FROM rnaseq LIMIT 5;
-- SELECT all columns from the table rnaseq using * with LIMIT 10
SELECT * FROM rnaseq LIMIT 10;
-- SELECT all columns from the table rnaseq using * with LIMIT 10
SELECT * FROM rnaseq LIMIT 10;
-- SELECT all columns from the table rnaseq using * with LIMIT 50
SELECT * FROM rnaseq LIMIT 50;
---------------------------------------------------------------------
-----------SELECT DISTINCT column_name FROM table_name;--------------
---------------------------------------------------------------------
---- Removing Duplicates from table table_name using SELECT DISTINCT column_name
SELECT DISTINCT column_name FROM table_name;
---- Removing Duplicates from table employee_info using SELECT DISTINCT Job
SELECT DISTINCT Job FROM employee_info;
---- Removing Duplicates from table employee_info using SELECT DISTINCT City
SELECT DISTINCT City FROM employee_info;
---- Removing Duplicates from the table rnaseq using SELECT DISTINCT RPKM
SELECT DISTINCT RPKM FROM rnaseq;
---- Removing Duplicates from the table rnaseq using SELECT DISTINCT Gene_Annotation
SELECT DISTINCT Gene_Annotation FROM rnaseq;
---- Removing Duplicates from the table rnaseq using SELECT DISTINCT Gene_length
SELECT DISTINCT Gene_length FROM rnaseq;
---- Removing Duplicates from the table rnaseq using SELECT DISTINCT Expression_values
SELECT DISTINCT Expression_values FROM rnaseq;
---- Removing Duplicates from the table rnaseq using SELECT DISTINCT Unique_gene_reads
SELECT DISTINCT Unique_gene_reads FROM rnaseq;
---- Removing Duplicates from the table rnaseq using SELECT DISTINCT Total_gene_read
'Active' AS Status,
0.22 * Salary AS Tax_paid, UPPER(Job) AS Job
FROM employee_info;
--- Concatenating Column Values:
SELECT CONCAT(Name, ' works as a ', Job) AS Description
FROM employee_info;
--- SELECT DISTINCT Statement
-------Syntax:
SELECT DISTINCT column_name FROM table_name;
SELECT DISTINCT column_name(s) FROM table_name;
------------SELECT DISTINCT Values:
SELECT Job FROM employee_info;
DISTINCT on Multiple Columns:
SELECT DISTINCT City, Job
FROM employee_info;
DISTINCT in Aggregate Functions:
SELECT DISTINCT City, Job
FROM employee_info;
DISTINCT in Aggregate Functions:
---------------------------------------------------------------
-------SELECT COUNT(DISTINCT column_name) FROM table_name;-----
---------------------------------------------------------------
---Counting DISTINCT columns from a table
SELECT COUNT(DISTINCT column_name) FROM table_name;
---Counting DISTINCT Job from employee_info
SELECT COUNT(DISTINCT Job)
FROM employee_info;
---Counting DISTINCT Gene_ID from rnaseq
SELECT COUNT(DISTINCT Gene_ID) FROM rnaseq;
---Counting DISTINCT Gene_Annotation from rnaseq
SELECT COUNT(DISTINCT Gene_Annotation) FROM rnaseq;
---Counting DISTINCT Expression_values from rnaseq
SELECT COUNT(DISTINCT Expression_values) FROM rnaseq;
---Counting DISTINCT Gene_length from rnaseq
SELECT COUNT(DISTINCT Gene_length) FROM rnaseq;
---Counting DISTINCT Unique_gene_reads from rnaseq
SELECT COUNT(DISTINCT Unique_gene_reads) FROM rnaseq;
---Counting DISTINCT Total_gene_read from rnaseq
SELECT COUNT(DISTINCT Total_gene_read) FROM rnaseq;
---Counting DISTINCT RPKM from rnaseq
SELECT COUNT(DISTINCT RPKM) FROM rnaseq;