C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




sql querry interview question


Posted Date: 10 Jul 2006      Total Responses: 6

Posted By: damodar       Member Level: Bronze     Points: 2


I have two tables one is emp table having columns
eid
ename
esal
another table named phone having columns
eid
phonenumber
Now i want to get the details of the employee who have two or more than two phone numbers
write the querry?




Responses

Author: chenna    10 Jul 2006Member Level: SilverRating:     Points: 2
Hi,

SELECT * FROM EMP
WHERE EID IN(SELECT DISTINCT EID FROM PHONE
GROUP BY EID
HAVING COUNT(*) >= 2)


OR

SELECT EMP.* FROM EMP E, PHONE P
WHRE E.EID = P.EID
GROUP BY E.EID, E.ENAME, E.ESAL
HAVING COUNT(*) >= 2

Thanks and Regards
-Kesav




Author: divya    13 Oct 2008Member Level: GoldRating:     Points: 1
select a.id from test a where a.id in(select b.id from test1 b group by b.id having count(*)>=1)


Author: Mahima Nayak    28 Oct 2008Member Level: BronzeRating:     Points: 4
SELECT eid, ename
FROM emp
WHERE (eid IN
(SELECT eid
FROM phonenumber
GROUP BY eid
HAVING (COUNT(*) >= 2)))



Author: T.Thirumala Reddy    07 Nov 2008Member Level: BronzeRating:     Points: 1
select * from emp
where eid=(select distinct eid from phone group by eid having(count(*)>1))


Author: Deepika Haridas    22 Nov 2008Member Level: DiamondRating:     Points: 2
SELECT EMP.* FROM EMP E, PHONE P WHRE E.EID = P.EID GROUP BY E.EID, E.ENAME, E.ESAL HAVING COUNT(*) >= 2



Author: Deepika Haridas    26 Nov 2008Member Level: DiamondRating:     Points: 2
SELECT eid, ename
FROM emp
WHERE (eid IN
(SELECT eid
FROM phonenumber
GROUP BY eid
HAVING (COUNT(*) >= 2)))



Post Reply
You must Sign In to post a response.
Next : sql querry
Previous : connection string for sql , pls help
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

efax

Contact Us    Privacy Policy    Terms Of Use