i have 3 employees 5 record in transaction table i want to select only 2 records of ecch emplyee in select query
Select query
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
i have 3 employees 5 record in transaction table i want to select only 2 records of ecch emplyee in select query
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
Sachin SinghRank #66 · 26.2K reputationPosted Nov 19, 2022, 3:50 AM EST
There are multiple ways
select * from (select *, Row_Number() over (partition by empName order by empId) as RN from tableName)t where RN<=2Vishal JoshiRank #377 · 6.7K reputationPosted Nov 18, 2022, 7:38 AM EST
Hello
Try below query.
SELECT * FROM employeeTable empParent WHERE ( SELECT COUNT(*) FROM employeeTable empsub WHERE empsub.name = empParent.name ) <= 2