Table Name: Emp
Table Name: Product
select pp.proname,pp.proid,pp.empid from
(
select t.aaa,empid from
(
select count(proid)as aaa,empid from product as p group by p.empid
) as t where t.aaa >= 2
) as t2 left join product as pp on t2.empid = pp.empid
EmpId | Name |
1 | Sagar |
2 | Raj |
3 | Mohan |
4 | Anand |
5 | Tiku |
Table Name: Product
ProductId | EmpId | ProductName |
1 | 1 | Product1 |
2 | 1 | Product2 |
3 | 2 | Product3 |
4 | 3 | Product4 |
5 | 5 | Product5 |
6 | 3 | Product6 |
select pp.proname,pp.proid,pp.empid from
(
select t.aaa,empid from
(
select count(proid)as aaa,empid from product as p group by p.empid
) as t where t.aaa >= 2
) as t2 left join product as pp on t2.empid = pp.empid
No comments:
Post a Comment