Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Left join
Message
De
27/06/2002 02:27:44
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00672381
Message ID:
00672792
Vues:
9
Thanks,
I think that was my problem!

>Jimmy,
>
>Datetime values are stored with millisecond level precision and we don't have access to the miliseconds, so using datetime in a join is rarely going to succeed. You need a UDF to convert your datetime to a minute precision value.
>
>function MinuteDateTime( ltValue )
>return left( ttoc( ltValue, 1 ), 12 )
>
>YOu can seed your curdates cursor
>
>
ltend=datetime()
>ltstart=ltend- 24 * 60 * 60 && 7200 is only 2 hours earlier
>*the seconds are changed to zero.
>
>CREATE CURSOR curDates (cMinute c(12) )
>do while ltstart<=ltend
>	INSERT INTO curdates (cMinute) VALUES ( MinuteDatetime( ltstart ) )
>	ltstart=ltstart+60
>enddo
>
>and then join:
>
>
SELECT curDates.cMinute, * FROM registrations
>  LEFT JOIN curdates
>    ON MinuteDateTime( Registrations.datetime ) = curdates.cMinute ;
>  ORDER BY curdates.cMinute
>  into cursor ctest
>
>
>>I would like to have a cursor as result with for each minute of the day a registration value if there is no registration for that period then I will change to .null. value to 0.
>>
>>ltend=datetime()
>>ltstart=ltend-7200
>>*the seconds are changed to zero.
>>
>>CREATE CURSOR curDates (dDatetime T)
>>do while ltstart<=ltend
>> INSERT INTO curdates (dDateTime) VALUES (ltstart)
>> ltstart=ltstart+60
>>enddo
>>
>>SELECT * FROM registrations right JOIN curdates ON Registrations.datetime=curdates.dDatetime ;
>> ORDER BY curdates.dDateTime into cursor ctest
>>
>>With this SQL-command I don't get a result the value-field is empty for all the dDatetime-records ??
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform