SELECT column_name, column_nameFROM table_nameORDER BY column_name ASC|DESC, column_name ASC|DESC;
উদাহরনঃ
SELECT*FROM CustomersORDER BY Country;
SELECT*FROM CustomersORDER BY Country DESC;
SELECT*FROM CustomersORDER BY Country ASC, CustomerName DESC;
GROUP BY
একই ধরনের ডাটার GROUP তৈরি করতে GROUP BY ক্লস ব্যবহৃত হয়ে থাকে।
SQL ORDER BY সিনট্যাক্স
SELECT column_name, aggregate_function(column_name)FROM table_nameWHERE column_name operator valueGROUP BY column_name;
উদাহরনঃ
SELECT Shippers.ShipperName,COUNT(Orders.OrderID) AS NumberOfOrders FROM OrdersLEFT JOIN ShippersON Orders.ShipperID=Shippers.ShipperIDGROUP BY ShipperName;
SELECT Shippers.ShipperName, Employees.LastName,COUNT(Orders.OrderID) AS NumberOfOrdersFROM ((OrdersINNER JOIN ShippersON Orders.ShipperID=Shippers.ShipperID)INNER JOIN EmployeesON Orders.EmployeeID=Employees.EmployeeID)GROUP BY ShipperName,LastName;
SQL Alias
আপনি চাইলে কোন টেবিল অথবা কলামের নাম সাময়িক ভাবে পরিবর্তন করতে পারেন এলিয়াস ব্যবহার করে।
SQL Alias সিনট্যাক্স
SELECT column_name AS alias_nameFROM table_name;
উদাহরনঃ
SELECT column_name(s)FROM table_name AS alias_name;
SELECT CustomerName AS Customer, ContactName AS Contact_PersonFROM Customers;