Wednesday, May 13, 2026

Filtering & Sorting (21–35)

 

  1. What does WHERE clause do?
    It filters rows based on conditions.
  2. Difference between WHERE and HAVING?
    WHERE filters rows before grouping; HAVING filters groups after aggregation.
  3. What is ORDER BY?
    It sorts query results in ascending or descending order.
  4. Default sort order in SQL?
    Ascending (ASC) by default.
  5. What is DISTINCT?
    It removes duplicate values from result.
  6. How do you fetch top 5 records?
    SELECT TOP 5 * FROM table; (SQL Server)
  7. How do you fetch first 5 rows in MySQL?
    SELECT * FROM table LIMIT 5;
  8. What is BETWEEN?
    It filters values within a range.
  9. What is IN operator?
    It matches values from a given list.
  10. What is LIKE used for?
    It is used for pattern matching.
  11. What does % mean in LIKE?
    It matches zero or more characters.
  12. What does _ mean in LIKE?
    It matches exactly one character.
  13. How do you handle NULL values?
    Use IS NULL or IS NOT NULL.
  14. Can we use = NULL?
    No, use IS NULL.
  15. What is alias in SQL?
    A temporary name given to a column or table.

No comments:

Post a Comment