Click here to Skip to main content
15,897,291 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Pls some one tell that what is the output of this query.

select the employee name who is having more than one phone number.



Pls some one tell.....
Posted

SQL
SELECT [CONTACTS].[EMP_NAME],COUNT([CONTACTS].[CONTACT_NO])
FROM   [dbo].CONTACTINFOTABLE AS [CONTACTS]
GROUP BY [CONTACTS].[EMP_NAME]
HAVING COUNT([CONTACTS].[CONTACT_NO]) > 0


if you do not use having clause in normal query where no grouping done. it will acts as normal where clause.
 
Share this answer
 
v2
select name, count(*) as TotalCount
from table_name
group by name
having count(*)>0


Your problem will be solved.
 
Share this answer
 
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'name'.


If you are trying to get us to convert these to SQL queries for you, (and I suspect you are from this and your other question) then you have to remember two things:
1) Ask us what you actually mean. If you ask us "what does this do?" then we will answer "This does such-and-such". If you need help designing a quesry, then ask for help desiogning a query, but show us what you have tried.
2) We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.
 
Share this answer
 
Comments
silvercr0w 7-Sep-13 11:41am    
I agree with your answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900