group by clause
how we can select first name whose salary is equal to 10000 group by department
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted May 11, 2014, 7:25 AM
It is not compulsory to use aggregate function with group by clause but columns with select statement must define in group by clause
try...
create Table #test
(
emp int,
salary money,
department int
)
insert into #test values(1,10000,1)
insert into #test values(2,1000,1)
insert into #test values(3,44444,1)
insert into #test values(4,10000,2)
insert into #test values(5,10000,3)
SELECT emp
FROM #test
WHERE Salary=10000
GROUP BY emp, department
hope this will help you.
Ranjit PowarPosted May 11, 2014, 2:15 AM
Sna khanPosted May 10, 2014, 2:31 PM
Abhay ShankerPosted May 10, 2014, 11:39 AM
SELECT firstname
FROM [TableName]
WHERE Salary=10000
GROUP BY department