Saturday, May 16, 2009

Write a query for the following question

The table tbl_sites contains the following data:

---------------------------------------
Userid sitename country
---------------------------------------
1 asp-interviewquestions.blogspot.com pakistan
2 c-sharp-interviewquestions.blogspot.com pakistan
3 PHP.net usa
4 PHPtalk.com germany
5 MySQL.com usa
6 sureshbabu canada
7 PHPbuddy.com pakistan
8. PHPtalk.com austria
9. PHPfreaks.com sourthafrica
10. PHPsupport.net russia
11. sureshbabu australia
12. sureshbabu nepal
13. PHPtalk.com italy

Write a select query that will be displayed the duplicated site name and how many times it is duplicated? …

SELECT sitename, COUNT(*) AS NumOccurrences
FROM tbl_sites
GROUP BY sitename HAVING COUNT(*) > 1

No comments:

Post a Comment