Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Fine tuning a SPROC
Message
De
21/06/2007 15:21:52
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01234693
Message ID:
01234865
Vues:
9
>>Am I doing something out of the ordinary here? I thought this was a pretty basic query.
>>
>No you didn't. But both tables are not related, that way SQL Server must compare each record from Table1 with all records in Table2.
>
>BTW with LEFT JOIN you will get as many records as there are matching date intervals in Table2. Can you post some example data and desired result from it?

Sure:
Table1
ID  |Field1   |Field2   |EffectiveDate
1   |1.12     |2.51     |1/1/2007
2   |1.45     |2.56     |1/2/2007
3   |1.76     |2.81     |1/3/2007

Table2
ID  |Field1   |Field2   |StartDate   |EndDate
1   |9.12     |10.54    |11/1/2006   |1/2/2007
2   |9.01     |12.45    |1/3/2007    |1/31/2007

The results I want are:
1/1/2007   |1.12  |2.51   |9.12   |10.54
1/2/2007   |1.45  |2.56   |9.12   |10.54
1/3/2007   |1.76  |2.81   |9.01   |12.45
Very fitting: http://xkcd.com/386/
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform