Skip to main content
Home
  • Tutorials
    • Quality Assurance
    • Software Development
    • Machine Learning
    • Data Science
  • About Us
  • Contact
programsbuzz facebook programsbuzz twitter programsbuzz linkedin
  • Log in

Main navigation

  • Tutorials
    • Quality Assurance
    • Software Development
    • Machine Learning
    • Data Science
  • About Us
  • Contact

Oracle Employee Database Case Study: Order By Clause

Profile picture for user akshita.goel
Written by akshita.goel on 12/14/2021 - 09:15

After completion with where Queries. Let's move ahead with the sorting of data in terms of Ascending and descending order. This kind of sorting in SQL is done using the ORDER BY Clause.
Let's move ahead with the queries based on an order by clause:

QUERY 1:LIST OUT THE EMPLOYEE ID, LAST NAME IN ASCENDING ORDER BASED ON THE EMPLOYEE ID.

Now as the query suggestions, we need to arrange the data, where the last name of an employee is sorted by arranging Employee ID in Ascending Order. Follow the below code to perform the same:

Select ID, Last_Name from employee order by ID;

OUTPUT:
Order By-Query1

QUERY 2: LIST OUT THE EMPLOYEE ID, NAME IN ASCENDING ORDER BASED ON SALARY.

Here, in this query, we need to sort the ID of the employee, by arranging the Salary of the employee in ascending order.

Select ID, First_Name, 
Middle_Name, Last_Name,Salary 
from Employee order by Salary;

OUTPUT:
Order By-Query2

QUERY 3: LIST OUT THE EMPLOYEE DETAILS ACCORDING TO THEIR LAST NAME IN ASCENDING ORDER.

This query demands, to arrange Data by arranging the Last_Name of the Employee in ascending order.
Find below the code, that performs the same task:

Select * from Employee Order by Last_Name;

OUTPUT:
Order By-Query3

QUERY 4: LIST OUT THE EMPLOYEE DETAILS ACCORDING TO THEIR LAST NAME IN ASCENDING ORDER AND THEN ON DEPARTMENT_ID IN DESCENDING ORDER.

To apply different sorting for two different types of columns follows the code as written below:

Select * from Employee order by Last_Name ASC,Department_id DESC;

OUTPUT:
Order By-Query4

Related Content
Oracle Employee Database Case Study: Where Conditions
Oracle Employee Database Case Study: Basic Queries
Oracle Employee Database Case Study: Insert Data Into Tables
  • Log in or register to post comments

Choose Your Technology

  1. Agile
  2. Apache Groovy
  3. Apache Hadoop
  4. Apache HBase
  5. Apache Spark
  6. Appium
  7. AutoIt
  8. AWS
  9. Behat
  10. Cucumber Java
  11. Cypress
  12. DBMS
  13. Drupal
  14. GitHub
  15. GitLab
  16. GoLang
  17. Gradle
  18. HTML
  19. ISTQB Foundation
  20. Java
  21. JavaScript
  22. JMeter
  23. JUnit
  24. Karate
  25. Kotlin
  26. LoadRunner
  27. matplotlib
  28. MongoDB
  29. MS SQL Server
  30. MySQL
  31. Nightwatch JS
  32. PactumJS
  33. PHP
  34. Playwright
  35. Playwright Java
  36. Playwright Python
  37. Postman
  38. Project Management
  39. Protractor
  40. PyDev
  41. Python
  42. Python NumPy
  43. Python Pandas
  44. Python Seaborn
  45. R Language
  46. REST Assured
  47. Ruby
  48. Selenide
© Copyright By iVagus Services Pvt. Ltd. 2023. All Rights Reserved.

Footer

  • Cookie Policy
  • Privacy Policy
  • Terms of Use