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
23 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,140 points
55 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,140 points
31 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,140 points
20 views
0 votes
1 answer

What is GROUP BY statement in MySQL?

This statement is used with the aggregate ...READ MORE

answered Nov 23, 2018 in Database by darklord
• 6,140 points
35 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,100 points
25 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,430 points
275 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,240 points
83 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,600 points
127 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
• 860 points
31 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
• 860 points
11 views