Sunday, June 28, 2020

Sorting Interview Questions Part 3


Sorting in SQL | Order By | Conditional Sorting| Unusual Sorting
(Click below for you tube video answer)


Q1. What is the default sorting using ORDER BY with out specifying Ascending or Descending? 

Default sorting using ORDER BY is Ascending



Q2. How the records of a table will be sorted using SELECT when there is no Primary Key?

The data will not be sorted in any particular order, records will be randomly be picked by SELECT statement

Q3. What is ORDER BY and how is it different from clustered index?

The ORDER BY clause sorts query results by one or more columns while retrieve the data from database.


Clustered index will physically sort data in the table. (Like the Index of a book)

Q4. How to sort the country Specific Country on top (e.g. India) and rest of the countries in the tblCountry table in Ascending order?



Q5. How to sort the data in specific order / Unusual order Specific Counties (UK, India and US) on top and order the rest of the countries in the tblCountry table in Ascending order? (conditional sorting)



Conclusion

Below is the summary of what we discussed. We can apply different conditions in order to sort the data. In next video, will see few more questions about SORTING.





No comments:

Post a Comment

  Printing Number Pattern using SQL Link for video answer: SQL: --********************* --PRINT Pattern --********************* -- 1 -- ...