Subject | AW: [firebird-support] firebird sql alias for condition |
---|---|
Author | Olaf Kluge |
Post date | 2013-06-24T06:56:02Z |
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
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]
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:t_zeitschaltuhr order by tmp into :tmp_next_e;
>
>select first 1 cast(d_ein || ' ' || z_ein as timestamp) as tmp from
>t_zeitschaltuhr order by tmp into :tmp_next_a;
>select first 1 cast(d_aus || ' ' || z_aus as timestamp) as tmp from
>after now. (Time to switch the machine next
>d_ein is a date, z_ein a time, I would like a timestamp and get the next
>time off and on:If you're on a recent Firebird version, Olaf, you can do something like:
>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?
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]