Learn with best explanation

Coding tutorials and solutions

Java Core Interview Questions

Frequently asked basic java questions

SQL Basic Interview Questions

SQL Keys

SQL Differences

Job oriented commonly asked SQL clauses interview questions and answers with example

Here we will learn about the differences between sql classes like WHERE and HAVING, UNION and UNION ALL, IN and EXISTS GROUP BY and ORDER BY, JOIN and SUBQUERY, JOIN and UNION. These classes are commonly asked in interview, we have explained and discussed with explanation and example one by one bellow

What is deference between WHERE and HAVING ?

Where and Having classes are used for filtering the rows in the database table. WHERE works on row data not on aggregate data. Following is the example of where clause.

SELECT * from student WHERE student_id = 1

HAVING works on aggregate data. An aggregate data is something on which calculation is performed using any of the following aggregate function.

  • COUNT()
  • MAX()
  • MIN()
  • AVG()
  • SUM()

GROUP BY statement groups rows that have the same values. It is mostly used with above aggregate functions. Following is the example having clause and group by statement.

SELECT SUM(marks) from subjects GROUP BY subjects HAVING COUNT(marks) > 75