Information générale
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
>Hello ,
>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 ??
I have tested with the NOT-clausule.
I would like to make a list of dates that are not included in the table registrations.
select curdates.dDatetime from curdates ;
WHERE curdates.dDatetime NOT IN (SELECT DISTINCT Datetime as dDatetime FROM registrations where ovenid==0)
If I run the first SQL-part 'select curdates.dDatetime from curdates', I have 241 results.
If I run the last SQL-part 'SELECT DISTINCT Datetime as dDatetime FROM registrations where ovenid==0' I have 16 results.
Normally I should get 241-16 records If I run the whole Sql-command 'select curdates.dDatetime from curdates ;
WHERE curdates.dDatetime NOT IN (SELECT DISTINCT Datetime as dDatetime FROM registrations where ovenid==0)' but I still get 241 results.
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement