Reputation: 786
As Previously I know the mysql group by function , but I really dont know my question is wrong or write, My question how to use group by function using paricular column single value , for ex : consider below datas
TAB : tab1
id name value
1 IN 1
2 IN 1
3 AU 2
4 AU 2
5 IN 3
Is it possible to group by using country particular value IN , like below
SELECT SUM(value),name FROM tab1 GROUP BY name.IN
I expect only ,
IN 5
If using where condition this would be achieve, but for some reason I need to do this way...but using this way shows error, Is there any other way to achieve this without using where condition , Any help appreciated...
Upvotes: 0
Views: 43
Reputation: 143
You can use having clause.
SELECT SUM(value),name FROM tab1 GROUP BY name HAVING name = 'IN'
Upvotes: 1