Group by clause
how we can select first name whose salary is equal to 10000 group by department
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jignesh TrivediRank #16 · 50.3K reputationPosted May 11, 2014, 3:25 AM EDT
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.
Abhay ShankerRank #375 · 6.7K reputationPosted May 10, 2014, 7:39 AM EDT
SELECT firstname
FROM [TableName]
WHERE Salary=10000
GROUP BY department
Sna khan19 reputationPosted May 10, 2014, 10:31 AM EDT
Ranjit PowarRank #553 · 4.4K reputationPosted May 10, 2014, 10:15 PM EDT