您好,在开始向您解释我的问题之前,首先,我想说的是,在Google中多次搜索此问题,但我无法找到满意的答案。 我的任务是在同一列中找到与另一个日期相等的日期
我尝试过:
select text, text as text1, date, date as 1
from task
where Date = Date1;
发生错误:Date1无效ID
数据:
Text | Date
---------+-----------
Sample1 | 2018 1 23
Sample2 | 2018 1 15
Sample3 | 2018 4 26
Sample4 | 2018 1 23
输出:
Text | Text1
---------+--------
Sample1 | Sample2
答案 0 :(得分:0)
select
T1.Text as Text,
T2.Text as Text1
from Task T1
inner Join Taks T2 on T1.Date = T2.Date
答案 1 :(得分:0)
这将起作用:
create table table301(col1 varchar(20),col2 date);
insert into table301 values('Sample1' , '23-jan-2018');
insert into table301 values('Sample2' , '15-jan-2018' );
insert into table301 values('Sample3' , '26-apr-2018');
insert into table301 values('Sample4' , '23-jan-018');
SELECT * FROM table301;
SELECT a.col1,b.col1 FROM table301 a ,table301 b where sysdate-
a.col2=sysdate-b.col2 and a.col1<>b.col1 and rownum<=1;
输出:
Sample4 Sample1