Hello,
thanks @ all. I just have one question. One dataset includes a date + time to switch on and a date + time to switch off. I would like to get the timestamp next time on and next time off. In the simplest case both times from one dataset are in the future. Now it can be, that the next time to switch on listed in one, the time to switch on in another dataset. --- with TmpTable(tmp) as (select cast(d_ein || ' ' || z_ein as timestamp) as t_ein, cast(d_aus || ' ' || z_aus as timestamp) as t_aus from t_zeitschaltuhr where d_ein >= current_date or d_aus > current_date and id_zum = 50 and id_zue < 8 and aktiv = 1) select t_ein from TmpTable where t_ein > 'now' order by t_ein rows 1 /* next time to switch on */ select t_aus from TmpTable where t_aus > 'now' order by t_aus rows 1 /* next time to switch off */ --- How can I read both selects at once? Thank you Best regards. Olaf >I did the following: > >select first 1 cast(d_ein || ' ' || z_ein as timestamp) as tmp from t_zeitschaltuhr order by tmp into :tmp_next_e; > >select first 1 cast(d_aus || ' ' || z_aus as timestamp) as tmp from t_zeitschaltuhr order by tmp into :tmp_next_a; > >d_ein is a date, z_ein a time, I would like a timestamp and get the next after now. (Time to switch the machine next >time off and on: >This time should be the next in the future, so I thought: where tmp > 'now' >, but I can't use the alias for the condition. What can I do? If you're on a recent Firebird version, Olaf, you can do something like: with TmpTable(tmp) as (select cast(d_ein || ' ' || z_ein as timestamp) as tmp from t_zeitschaltuhr where d_ein >= current_date) select tmp from TmpTable where tmp > 'now' order by tmp rows 1 HTH, Set [Non-text portions of this message have been removed]
