Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Legal SQL command?

Author  Topic 

WinterPhoenix
Starting Member

2 Posts

Posted - 2008-03-26 : 22:08:02
For a class I am taking, I have to write a SQL statement to return emails that show up in a table more than once. The schema for the table is:

Table: Users
Email - Varchar(75)
City - Varchar(75)
State - Char(2)

I have a proposed solution, but I am not sure it would work since there is no concrete implementation of this. The class is still doing basic SQL, so forgive my inexperience.

SELECT Email FROM Users WHERE (COUNT(Email) > 1)

Is this a valid solution? Thank you for any help

WinterPhoenix

nr
SQLTeam MVY

12543 Posts

Posted - 2008-03-26 : 22:13:29
nope - needs a group by clause

SELECT Email
FROM Users
group by Email
having count(*) > 1

Don't you have anything you can test a query on?
If not download sql server express and install it.
Access would probably do as well.


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

WinterPhoenix
Starting Member

2 Posts

Posted - 2008-03-26 : 22:22:58
Thank you very much, nr. I don't have a proper testing environment, but the actual course only touches on SQL for another couple days. As a software engineering student, however, I certainly should learn database management - and soon.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2008-03-27 : 09:31:05
I would start with Data modeling

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -