What is the rule to use group by, having and where clause?

0 votes
Hey,

I want to use where, group by and having in a same query but I am getting syntax error. So what is the sequence to use these at a time?
Jul 2 in Database by Samar
58 views

1 answer to this question.

0 votes

Hi samar,

this is a very common mistake .\

So if you want to use there three at a time in one query then the sequence will be - where-group by -having

example:

Select * from employee where age>=32 group by(department_id) having count(transaction_id) >1

Thank you,

I hope it will help you

answered Jul 2 by anonymous

Related Questions In Database

0 votes
1 answer

What is the SQL query to get the third highest salary of an employee from employee_table

You can try out something like this: SELECT ...READ MORE

answered Sep 26, 2018 in Database by darklord
• 6,170 points
482 views
0 votes
1 answer

What is HAVING Clause in MySQL?

Since the WHERE keyword cannot be used with aggregate ...READ MORE

answered Nov 21, 2018 in Database by darklord
• 6,170 points
53 views
0 votes
1 answer

What is the ORDER BY statement in MySQL?

This statement is used to sort the ...READ MORE

answered Nov 23, 2018 in Database by darklord
• 6,170 points
37 views
0 votes
1 answer

IN vs OR in the SQL WHERE Clause

I assume you want to know the ...READ MORE

answered Sep 24, 2018 in Database by DataKing99
• 8,130 points
41 views
0 votes
0 answers

How to use the where clause in R programming?

I'm trying to implement a where clause ...READ MORE

Dec 24, 2018 in Data Analytics by Sophie may
• 9,870 points
514 views
0 votes
1 answer

Which query to use for better performance, join in SQL or using Dataset API?

DataFrames and SparkSQL performed almost about the ...READ MORE

answered Apr 19, 2018 in Apache Spark by kurt_cobain
• 9,260 points
134 views
0 votes
1 answer

How to connect Java program to the MySQL database?

You can connect your Java code with ...READ MORE

answered May 11, 2018 in Java by parth295
• 4,640 points
214 views
0 votes
1 answer

Do I need to add primary key in each and every table?

Hi Shraddha, You have a doubt to add ...READ MORE

answered May 29 in Database by sampriti
• 1,100 points
51 views
0 votes
1 answer

How to sort the data in sql ?

Hi Akash,  If you want to sort ...READ MORE

answered May 29 in Database by sampriti
• 1,100 points
34 views