SQL – GROUP BY and ORDER BY

SQL - GROUP BY and ORDER BY

SQL – GROUP BY and ORDER BY: Here, we will figure out how to frame records based on certain normal components and Order By to show them in climbing and slipping request.

Syntax:

SELECT column_names FROM table_names WHERE condition 
GROUP BY column_name 
HAVING condition 
ORDER BY column_name ASC/DESC;

Gathering BY is utilized to frame a gathering of records based on a specific regular component in the records. Request BY is utilized to organize record either in rising or dropping request in a table.

Here,

  • Column_names: are the name of the fields in the table
  • table_name: name of the table from which we need to bring information
  • condition: use to channel information

Note: If we don’t indicate ASC or DESC all together BY it will as a matter, of course, accept it as rising request.

Test table (Student),

SQL - GROUP BY and ORDER BY

1) Select Student and gathering them by city

SQL - GROUP BY and ORDER BY

2) Select Student and gathering them by the city in slipping request

SQL - GROUP BY and ORDER BY

Recent Posts

error: Alert: Content is protected!!