Sql 你不想要。最后声明?和to_number(to_char(dateCol2,'hh24mi'))
Sql 你不想要。最后声明?和to_number(to_char(dateCol2,'hh24mi')),sql,oracle,Sql,Oracle,你不想要。最后声明?和to_number(to_char(dateCol2,'hh24mi'))
你不想要。最后声明?
和to_number(to_char(dateCol2,'hh24mi'))<1730
部分获取小于17:30的所有记录。这就是你想要的?几乎我想要的是最后一个(也是第一个,但我想这只是一个不同的函数)小于17的记录:30@statquant我懂了。使用行编号()
查看最后一次SQL编辑,它将仅获取datecol2小于1730的第一行(最小)和最后一行(最大)。例如@DazzaL-你不需要按datecol
对它们进行划分吗?@AlexPoole因为posters查询是一个固定的单独日期,那么在这个特定的情况下就不需要了,尽管也许在他们调整它的情况下,拥有它可能更清楚there@statquant如果datecol
始终为00:00:00,则第二个变量就是您想要的。最后声明?和to_number(to_char(dateCol2,'hh24mi'))<1730
部分获取小于17:30的所有记录。这就是你想要的?几乎我想要的是最后一个(也是第一个,但我想这只是一个不同的函数)小于17的记录:30@statquant我懂了。使用行编号()
查看最后一次SQL编辑,它将仅获取datecol2小于1730的第一行(最小)和最后一行(最大)。例如@DazzaL-你不需要按datecol
来划分吗?@AlexPoole,因为海报查询是一个固定的单独日期,那么在这个特定的情况下就不需要了,尽管也许在他们调整它的情况下,可能会更清楚地得到它,我只是无法在这个代码中插入主要的内容。您必须以:groupbytrunc(t.dateCol)结束这段代码。不幸的是,我无法在这段代码中插入主要内容。此代码必须以:group by trunc(t.dateCol)结尾
select * from table where dateCol between to_date('2013-01-01 00:00:00','YYYY-MM-DD H24:MI:SS') and to_date('2013-02-01 00:00:00','YYYY-MM-DD H24:MI:SS')
and id='myID'
and [MISSING PART = the last line such that timepart(dateCol2)<'17:30']
select * from (select table.*, row_number() over (order by dateCol2 desc) last_row from table
where dateCol between to_date('2013-01-01 00:00:00','YYYY-MM-DD H24:MI:SS')
and to_date('2013-02-01 00:00:00','YYYY-MM-DD H24:MI:SS')
and id='myID'
and to_char(dateCol2, 'hh24:mi') < '17:30')
where last_row = 1
group by dateCol
)
select distinct dateCol
from table
where dateCol >= to_date('2013-01-01','YYYY-MM-DD')
and dateCol < to_date('2013-01-01','YYYY-MM-DD') + 1
and id='myID'
and to_number(to_char(dateCol2, 'hh24mi')) < 1730;
select distinct dateCol
from table
where dateCol = to_date('2013-01-01','YYYY-MM-DD')
and id='myID'
and to_number(to_char(dateCol2, 'hh24mi')) < 1730;
select *
from (select t.*, row_number() over (partition by datecol
order by dateCol2) first_row,
row_number() over (partition by datecol
order by dateCol2 desc) last_row
from table t
where dateCol = to_date('2013-01-01','YYYY-MM-DD')
and id='myID'
and to_number(to_char(dateCol2, 'hh24mi')) < 1730)
where first_row = 1
or last_row = 1;
select *
from table
where (dateCol, dateCol2) in (
select dateCol, max(dateCol2)
from table
where dateCol between to_date('2013-01-01','YYYY-MM-DD')
and to_date('2013-01-01','YYYY-MM-DD')
and id='myID'
and to_char(dateCol2, 'hh24:mi') < '17:30'
group by dateCol
)
select *
from table t
innner join (
select dateCol,
min(dateCol2) first,
max(dateCol2) last
from table
where trunc(dateCol) = to_date('2013-01-01','YYYY-MM-DD')
and id='myID'
and to_char(dateCol2, 'hh24:mi') < '17:30'
group by dateCol
)
sub s
on t.dateCol = s.dateCol
and (t.dateCol2 = s.first
or t.dateCol2 = s.last)
select * from table
where dateCol between to_date('2013-01-01','YYYY-MM-DD')
and to_date('2013-01-01','YYYY-MMDD')
and id='myID' and dateCol<trunc(dateCol)+17.5/24
select trunc(t.dateCol),
max(t.your_column) keep (dense_rank last order by t.dateCol)
from table t
where t.dateCol between to_date('2013-01-01','YYYY-MM-DD') and to_date('2013-05-01','YYYY-MM-DD')
and t.id='myID'
and t.dateCol