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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 help with select

Author  Topic 

pelegk2
Aged Yak Warrior

723 Posts

Posted - 2007-01-16 : 02:12:53
i have 2 columns :
1 -presson passport number
2 - time which is this this : yyyymmddhhmmss
and a passport+time can appear more then once with the same time
(for example sending a message to a lot of pepole will write the same time)
how can i check which of the pepole have more then 1 row in the DB
in the same SECOND!
for example :
1111 20070116163232
1111 20070116163232
in this case passpot number 1111 has 2 rows

thnaks in advance
peleg

Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-16 : 02:17:26
select col1, col2 from yourtable group by col1, col2 having count(*) > 1


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-16 : 02:18:27
I am amazed. Over 300 posts and still have no clue of GROUP BY.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

pelegk2
Aged Yak Warrior

723 Posts

Posted - 2007-01-16 : 02:28:33
i do have but the soluton u gave me which i know dosent solve it
sorry if i didnt make it clear i need every passport to appear only once

Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-16 : 02:38:56
How to modify my suggestion to deal with new information?

select distinct col1, col2 from yourtable group by col1, col2 having count(*) > 1


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

pelegk2
Aged Yak Warrior

723 Posts

Posted - 2007-01-16 : 02:54:36
thnaks alot

Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)
Go to Top of Page
   

- Advertisement -