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.
| Author |
Topic |
|
ledwallet
Starting Member
3 Posts |
Posted - 2008-01-09 : 14:56:40
|
| Hi,I'm working with slq server 2005, i'm looking for a solution of my problem:I have table "A" with with 7 row, one of them is a date format like "10/01/2008" and another table "B" with only the field date distinct from table "A", with tha same format.I need to compare the two filds date for to know how many are double on the table "A".I hope my explication is ok.bye |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2008-01-09 : 15:27:54
|
| Cant tell exactly what u r after, but one of these sounds like what u need...SELECT datefield, count(datefield) cFROM tableAGROUP BY datefieldHAVING Count(datefield) > 1SELECT a.datefield, count(a.datefield) cFROM tableA aJOIN tableB bOn a.datefield = b.datefieldGROUP BY a.datefieldHAVING Count(a.datefield) > 1 |
 |
|
|
ledwallet
Starting Member
3 Posts |
Posted - 2008-01-09 : 15:54:24
|
Ok it's works!!!Now i know for a determinate date how many them are, but...in the tableA i have a lot of rows, informations, but how can i put those in relation with those date?I have to know now the full information from tableA.quote: Originally posted by russell Cant tell exactly what u r after, but one of these sounds like what u need...SELECT datefield, count(datefield) cFROM tableAGROUP BY datefieldHAVING Count(datefield) > 1SELECT a.datefield, count(a.datefield) cFROM tableA aJOIN tableB bOn a.datefield = b.datefieldGROUP BY a.datefieldHAVING Count(a.datefield) > 1
|
 |
|
|
rohitkumar
Constraint Violating Yak Guru
472 Posts |
Posted - 2008-01-09 : 16:38:17
|
| SELECT * FROM tableA where datefield in (SELECT datefield FROM tableAGROUP BY datefieldHAVING Count(datefield) > 1) |
 |
|
|
|
|
|
|
|