1

例如。我有这个查询

select distinct t1.date1, t2.date2
from t1
join t2 ...
....
where ...

我想获取这 2 个日期的唯一值列表。我如何在 Firebird 2.5 上执行此操作?

我试试这个

with dates as (
select t1.date1 d1, t2.date2 d2
from t1
join t2 ...
....
where ...)
select d1 from dates
union
select d2 from dates

但是这个版本会降低性能两倍

4

1 回答 1

1

试试这个:

with dates (dt) as (
  select t1.date1 from t1
  where (1=1) --conditions

  union

  select t2.date2 from t2
  where (1=1) --conditions
)

select unique dt
from dates
于 2012-10-03T13:22:34.060 回答