由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - SQL问题(有包子)
相关主题
SQL Server - convert datetime to a string YY-MM-DD HHurgent: how to compare two dates in SQL?
请帮忙在PL/SQL里面执行下面的计算,一个笔记软件破解用的有大侠知道怎么format下面这个query的时间么
菜鸟请教一个关于oracle里日期的问题business analyst (SQL) opening in NYC
请教各位大侠呀.考古了半天,大家说的db developer和一般的programmer有什么
oracle help?advices please on learning Oracle
Oracle 求助Oracle证书
一道题 PL/SQLWeb Seminar hosted by CINAOUG on 2011/06/13
SQL, recruiter发过来的面试题 (转载)怎么准备第一份DBA工作
相关话题的讨论汇总
话题: datepart话题: date话题: sql话题: jan话题: 2012
进入Database版参与讨论
1 (共1页)
B*****g
发帖数: 34098
1
大家都不参加包子贴?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
写一个SQL,找出next N business days (N>0)。
假设已有fucntion isBusinessDay(date), return 1 for business day and 0 for
non-business day.
可以用任何数据库,不许假设M天之内必有N个business days。
第一个打出来的发双簧包,答案符合ANSI的包子加倍。
y****w
发帖数: 3747
2
holiday算哪几天?

【在 B*****g 的大作中提到】
: 大家都不参加包子贴?
: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
: 写一个SQL,找出next N business days (N>0)。
: 假设已有fucntion isBusinessDay(date), return 1 for business day and 0 for
: non-business day.
: 可以用任何数据库,不许假设M天之内必有N个business days。
: 第一个打出来的发双簧包,答案符合ANSI的包子加倍。

B*****g
发帖数: 34098
3
isBusinessDay, haha

【在 y****w 的大作中提到】
: holiday算哪几天?
a9
发帖数: 21638
4
beijing做dba做傻了,这种题目为什么要放到sql里来做?

【在 B*****g 的大作中提到】
: 大家都不参加包子贴?
: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
: 写一个SQL,找出next N business days (N>0)。
: 假设已有fucntion isBusinessDay(date), return 1 for business day and 0 for
: non-business day.
: 可以用任何数据库,不许假设M天之内必有N个business days。
: 第一个打出来的发双簧包,答案符合ANSI的包子加倍。

y****w
发帖数: 3747
5
教recursive sql。

【在 a9 的大作中提到】
: beijing做dba做傻了,这种题目为什么要放到sql里来做?
B*****g
发帖数: 34098
6
Tom Kyte’s:
You should do it in a single SQL statement if at all possible.
If you cannot do it in a single SQL Statement, then do it in PL/SQL.
If you cannot do it in PL/SQL, try a Java Stored Procedure.
If you cannot do it in Java, do it in a C external procedure.
If you cannot do it in a C external routine, you might want to seriously think about why it is you need to do it…
一些问题developer不用SQL不是因为SP更好,而是因为developer写不出SQL

【在 a9 的大作中提到】
: beijing做dba做傻了,这种题目为什么要放到sql里来做?
B*****g
发帖数: 34098
7
就你明白,p

【在 y****w 的大作中提到】
: 教recursive sql。
g***l
发帖数: 18555
8
我有现成的,哈哈
g***l
发帖数: 18555
9
首先要有一个FUNCTION判断是不是BUSINESS DATE,别忘了HOLIDAY
create function [dbo].[udf_is_valid_business_date]
(
@date datetime
)
returns int
as
begin
declare
@is_holiday int,
@is_valid_business_date int
select @is_holiday =
case
-- memorial day (last mon of may)
when datepart(yy,@date) = 2009 and datepart(mm,@date) = 5 and
datepart(dd,@date) = 25 then 1
when datepart(yy,@date) = 2010 and datepart(mm,@date) = 5 and
datepart(dd,@date) = 31 then 1
when datepart(yy,@date) = 2011 and datepart(mm,@date) = 5 and
datepart(dd,@date) = 30 then 1
when datepart(yy,@date) = 2012 and datepart(mm,@date) = 5 and
datepart(dd,@date) = 28 then 1
when datepart(yy,@date) = 2013 and datepart(mm,@date) = 5 and
datepart(dd,@date) = 27 then 1
when datepart(yy,@date) = 2014 and datepart(mm,@date) = 5 and
datepart(dd,@date) = 26 then 1
-- thanksgiving (last thu of nov plus 1 day after that)
when datepart(yy,@date) = 2008 and datepart(mm,@date) = 11 and
datepart(dd,@date) in (27, 28) then 1
when datepart(yy,@date) = 2009 and datepart(mm,@date) = 11 and
datepart(dd,@date) in (26, 27) then 1
when datepart(yy,@date) = 2010 and datepart(mm,@date) = 11 and
datepart(dd,@date) in (25, 26) then 1
when datepart(yy,@date) = 2011 and datepart(mm,@date) = 11 and
datepart(dd,@date) in (24, 25) then 1
when datepart(yy,@date) = 2012 and datepart(mm,@date) = 11 and
datepart(dd,@date) in (29, 30) then 1
when datepart(yy,@date) = 2013 and datepart(mm,@date) = 11 and
datepart(dd,@date) in (28, 29) then 1
-- labor day (1st mon of Sep)
when datepart(yy,@date) = 2008 and datepart(mm,@date) = 9 and
datepart(dd,@date) = 1 then 1
when datepart(yy,@date) = 2009 and datepart(mm,@date) = 9 and
datepart(dd,@date) = 7 then 1
when datepart(yy,@date) = 2010 and datepart(mm,@date) = 9 and
datepart(dd,@date) = 6 then 1
when datepart(yy,@date) = 2011 and datepart(mm,@date) = 9 and
datepart(dd,@date) = 5 then 1
when datepart(yy,@date) = 2012 and datepart(mm,@date) = 9 and
datepart(dd,@date) = 3 then 1
when datepart(yy,@date) = 2013 and datepart(mm,@date) = 9 and
datepart(dd,@date) = 2 then 1
-- 4th of July (every year)
when datepart(mm,@date) = 7 and datepart(dd,@date) = 4 then 1
-- Xmas (25 dec every year)
when datepart(mm,@date) = 12 and datepart(dd,@date) = 25 then 1
-- New Years (1 jan every year)
when datepart(mm,@date) = 1 and datepart(dd,@date) = 1 then 1
--
else 0
end
-- Everytime we encouter a weekend day or holiday, we must add one day
to the shipping estimate
if( (datepart(dw, @date) = 1) or (datepart(dw, @date) = 7) or (@is_
holiday = 1) )
begin
select
@is_valid_business_date = 0
end
else
begin
select
@is_valid_business_date = 1
end
return @is_valid_business_date
end
B*****g
发帖数: 34098
10
不会真有人写SQL吧,哈哈

【在 g***l 的大作中提到】
: 我有现成的,哈哈
相关主题
Oracle 求助urgent: how to compare two dates in SQL?
一道题 PL/SQL有大侠知道怎么format下面这个query的时间么
SQL, recruiter发过来的面试题 (转载)business analyst (SQL) opening in NYC
进入Database版参与讨论
a9
发帖数: 21638
11
这种东西,我一般就写到应用里了。

think about why it is you need to do it…

【在 B*****g 的大作中提到】
: Tom Kyte’s:
: You should do it in a single SQL statement if at all possible.
: If you cannot do it in a single SQL Statement, then do it in PL/SQL.
: If you cannot do it in PL/SQL, try a Java Stored Procedure.
: If you cannot do it in Java, do it in a C external procedure.
: If you cannot do it in a C external routine, you might want to seriously think about why it is you need to do it…
: 一些问题developer不用SQL不是因为SP更好,而是因为developer写不出SQL

g***l
发帖数: 18555
12
我只到了2013,不过还能优化,按星期几走就不需要LIST,这段不是我写的,我写的肯
定比这个好。LOL
B*****g
发帖数: 34098
13
俺的问题是已有这个function,用这个写SQL

【在 g***l 的大作中提到】
: 我只到了2013,不过还能优化,按星期几走就不需要LIST,这段不是我写的,我写的肯
: 定比这个好。LOL

g***l
发帖数: 18555
14
用个WHILE LOOP不就行了,从GETDATE()开始+1,直到IS_BUSINESS_DATE

【在 B*****g 的大作中提到】
: 俺的问题是已有这个function,用这个写SQL
B*****g
发帖数: 34098
15
sql only

【在 g***l 的大作中提到】
: 用个WHILE LOOP不就行了,从GETDATE()开始+1,直到IS_BUSINESS_DATE
g***l
发帖数: 18555
16
declare
@next_business_date datetime,
@is_business_date int
select @next_business_date = convert(datetime, convert(varchar,getdate(),101))
while (@is_business_date = 0)
begin
select @is_business_date = dbo.udf_is_valid_business_date(@next_business_date)
if (@is_business_date =0)
begin
select @next_business_date = @next_business_date + 1
end
end
select @next_business_date
B*****g
发帖数: 34098
17
还是给你发个安慰包

101))
date)

【在 g***l 的大作中提到】
: declare
: @next_business_date datetime,
: @is_business_date int
: select @next_business_date = convert(datetime, convert(varchar,getdate(),101))
: while (@is_business_date = 0)
: begin
: select @is_business_date = dbo.udf_is_valid_business_date(@next_business_date)
: if (@is_business_date =0)
: begin
: select @next_business_date = @next_business_date + 1

c*******e
发帖数: 8624
18
用qualify不行吗?

【在 B*****g 的大作中提到】
: sql only
B*****g
发帖数: 34098
19
不懂,是ANSI吗?

【在 c*******e 的大作中提到】
: 用qualify不行吗?
c*******e
发帖数: 8624
20
不是
qualify row_number() over (order by xxx) <= N

【在 B*****g 的大作中提到】
: 不懂,是ANSI吗?
相关主题
考古了半天,大家说的db developer和一般的programmer有什么Web Seminar hosted by CINAOUG on 2011/06/13
advices please on learning Oracle怎么准备第一份DBA工作
Oracle证书比较sqlplus和sql developer
进入Database版参与讨论
B*****g
发帖数: 34098
21
把完全SQL写出来吧

【在 c*******e 的大作中提到】
: 不是
: qualify row_number() over (order by xxx) <= N

c*******e
发帖数: 8624
22
sel data_dt from your_table
where data_dt > date
and biz_day_ind = 'Y'
qualify row_number() over (order by data_dt asc) <= N
order by 1 ;
假设table里面日期都是distinct的,如果不是distinct
就变成distinct,你懂的

【在 B*****g 的大作中提到】
: 把完全SQL写出来吧
B*****g
发帖数: 34098
23
木有table。从system date后数N天business day,显示出来。有table就是老问题,90
%的数据库版SQL问题可以用partition by解决。

【在 c*******e 的大作中提到】
: sel data_dt from your_table
: where data_dt > date
: and biz_day_ind = 'Y'
: qualify row_number() over (order by data_dt asc) <= N
: order by 1 ;
: 假设table里面日期都是distinct的,如果不是distinct
: 就变成distinct,你懂的

c*******e
发帖数: 8624
24
用sys_calendar不可以吗?

90

【在 B*****g 的大作中提到】
: 木有table。从system date后数N天business day,显示出来。有table就是老问题,90
: %的数据库版SQL问题可以用partition by解决。

B*****g
发帖数: 34098
25
算你也对,给你发一个双簧包。不过要是不是日期(比如说已有isZhiShu的function,
返回前100个质数)或者是我要100000000天(超了SYS_CALENDAR范围)你就没辙了。

【在 c*******e 的大作中提到】
: 用sys_calendar不可以吗?
:
: 90

y****9
发帖数: 144
26
Can I assume to find next N business day within certain number of years?
If N=10, if find next 10 biz day in 2012, and if today is Dec-23,2012, so it
won't have 10 biz days, is it sill ok for the requirement?

【在 B*****g 的大作中提到】
: 大家都不参加包子贴?
: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
: 写一个SQL,找出next N business days (N>0)。
: 假设已有fucntion isBusinessDay(date), return 1 for business day and 0 for
: non-business day.
: 可以用任何数据库,不许假设M天之内必有N个business days。
: 第一个打出来的发双簧包,答案符合ANSI的包子加倍。

B*****g
发帖数: 34098
27
其实这个题出的不好,不如改成前N个质数,更实际一些。
其实不给上限比给上限就多怎么加一个限制,让那个产生很多天list的SQL到特定位置
停止
~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~
it
y****9
发帖数: 144
28
Sorry, don't understand your reply.Don't know how to do it without upper
limit, but if to find next 10 biz days in 2012, I can do this as follows:
SQL>select mydate
2 from
3 (
4 select to_char(sysdate + level, 'YYYY-Mon-DD') mydate, level
5 from dual
6 where mod(to_number(to_char(sysdate + level, 'YYYYMMDD')),3) = 0 --
equivalent to isBIzDay(sysdate+level) =1
7 connect by level < to_date('2012-12-31','YYYY-MM-DD') - sysdate
8 )
9 where rownum <=10;
MYDATE
-----------
2012-Jan-09
2012-Jan-12
2012-Jan-15
2012-Jan-18
2012-Jan-21
2012-Jan-24
2012-Jan-27
2012-Jan-30
2012-Feb-02
2012-Feb-05
10 rows selected.

【在 B*****g 的大作中提到】
: 其实这个题出的不好,不如改成前N个质数,更实际一些。
: 其实不给上限比给上限就多怎么加一个限制,让那个产生很多天list的SQL到特定位置
: 停止
: ~~~~~~~~~~~~~~~
: ~~~~~~~~~~~~~~~
: it

B*****g
发帖数: 34098
29
connect by不要用level,用r*****

【在 y****9 的大作中提到】
: Sorry, don't understand your reply.Don't know how to do it without upper
: limit, but if to find next 10 biz days in 2012, I can do this as follows:
: SQL>select mydate
: 2 from
: 3 (
: 4 select to_char(sysdate + level, 'YYYY-Mon-DD') mydate, level
: 5 from dual
: 6 where mod(to_number(to_char(sysdate + level, 'YYYYMMDD')),3) = 0 --
: equivalent to isBIzDay(sysdate+level) =1
: 7 connect by level < to_date('2012-12-31','YYYY-MM-DD') - sysdate

B*****g
发帖数: 34098
30
总结一下,其实大家把问题想太复杂了,尤其是咱用oracle的兄弟,其实就是个简单的
SQL。我其实是想大家用recursive SQL做。
yhwang,你写个recursive sql吧,俺写的似乎太复杂
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
写一个SQL,找出next N business days (N>0)。
假设已有fucntion isBusinessDay(date), return 1 for business day and 0 for
non-business day.
可以用任何数据库,不许假设M天之内必有N个business days。
第一个打出来的发双簧包,答案符合ANSI的包子加倍。
相关主题
招db developer, dba (austin tx)请帮忙在PL/SQL里面执行下面的计算,一个笔记软件破解用的
请问有没有带DBA培训的美国CC菜鸟请教一个关于oracle里日期的问题
SQL Server - convert datetime to a string YY-MM-DD HH请教各位大侠呀.
进入Database版参与讨论
y****9
发帖数: 144
31

Thanks. Learned sth new today.
SQL>select to_char(sysdate + level, 'YYYY-Mon-DD') mydate
2 from dual
3 where mod(to_number(to_char(sysdate + level, 'YYYYMMDD')),3) = 0 --
equivalent to isBIzday(sysdate+level) =1
4 connect by rownum <=15
5 ;
MYDATE
-----------
2012-Jan-09
2012-Jan-12
2012-Jan-15
2012-Jan-18
2012-Jan-21
2012-Jan-24
2012-Jan-27
2012-Jan-30
2012-Feb-02
2012-Feb-05
2012-Feb-08
2012-Feb-11
2012-Feb-14
2012-Feb-17
2012-Feb-20
15 rows selected.

【在 B*****g 的大作中提到】
: connect by不要用level,用r*****
y****w
发帖数: 3747
32
with t(d,n) as
(
select current date, case when dayofweek_iso(current date) < 6 then
1 else 0 end from dual
union all
select t.d + 1 day, t.n+ case when dayofweek_iso(t.d+1 day) < 6 then
1 else 0 end from t where t.n < N
)
select min(d) from t group by n order by 1;
把case when dayofweek_iso调用换成你的isbusinessday。

【在 B*****g 的大作中提到】
: 总结一下,其实大家把问题想太复杂了,尤其是咱用oracle的兄弟,其实就是个简单的
: SQL。我其实是想大家用recursive SQL做。
: yhwang,你写个recursive sql吧,俺写的似乎太复杂
: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
: 写一个SQL,找出next N business days (N>0)。
: 假设已有fucntion isBusinessDay(date), return 1 for business day and 0 for
: non-business day.
: 可以用任何数据库,不许假设M天之内必有N个business days。
: 第一个打出来的发双簧包,答案符合ANSI的包子加倍。

y****w
发帖数: 3747
33
接着写isBusinessDay吧, 过程或sql,返回一个int, 1 or 0.
用这里的federal holiday作参考,
http://en.wikipedia.org/wiki/Public_holidays_in_the_United_Stat
B*****g
发帖数: 34098
34
我一开始就这么写,结果oracle啃爹了,大家看看下面为啥不work?我简化了一下
with t(d,n) as
(
select sysdate, 1
from dual
union all
select t.d+1, t.n +1
from t
where t.n < 10
)
select * from t
下面这个work,bug?
with t(d,n) as
(
select 1, 1
from dual
union all
select t.d+1, t.n +1
from t
where t.n < 10
)
select * from t

then
then

【在 y****w 的大作中提到】
: with t(d,n) as
: (
: select current date, case when dayofweek_iso(current date) < 6 then
: 1 else 0 end from dual
: union all
: select t.d + 1 day, t.n+ case when dayofweek_iso(t.d+1 day) < 6 then
: 1 else 0 end from t where t.n < N
: )
: select min(d) from t group by n order by 1;
: 把case when dayofweek_iso调用换成你的isbusinessday。

y****9
发帖数: 144
35

then
then
Learning SQL server now :-) Based on your sql structure; the following
works in SQL Server 2005
WITH t(d,n)
AS ( SELECT getdate(), case when day(getdate())%3=0 then 1 else
0 end
UNION ALL
SELECT t.d+ 1, t.n + case when day(t.d +1)%3=0 then 1 else
0 end
FROM t
WHERE t.n < 10
)
select min(d) from t
group by n
order by 1;
-----------------------
2012-01-06 13:27:25.843
2012-01-09 13:27:25.843
2012-01-12 13:27:25.843
2012-01-15 13:27:25.843
2012-01-18 13:27:25.843
2012-01-21 13:27:25.843
2012-01-24 13:27:25.843
2012-01-27 13:27:25.843
2012-01-30 13:27:25.843
2012-02-03 13:27:25.843
(10 row(s) affected)
HOwever if i do t.n< 50, I got:
-----------------------
Msg 530, Level 16, State 1, Line 2
The statement terminated. The maximum recursion 100 has been exhausted
before statement completion.
Is recursion level configurable in SQL server?

【在 y****w 的大作中提到】
: with t(d,n) as
: (
: select current date, case when dayofweek_iso(current date) < 6 then
: 1 else 0 end from dual
: union all
: select t.d + 1 day, t.n+ case when dayofweek_iso(t.d+1 day) < 6 then
: 1 else 0 end from t where t.n < N
: )
: select min(d) from t group by n order by 1;
: 把case when dayofweek_iso调用换成你的isbusinessday。

B*****g
发帖数: 34098
36
有没有oracle11g试一下,俺一直出问题,只好绕一个大圈做

else
else

【在 y****9 的大作中提到】
:
: then
: then
: Learning SQL server now :-) Based on your sql structure; the following
: works in SQL Server 2005
: WITH t(d,n)
: AS ( SELECT getdate(), case when day(getdate())%3=0 then 1 else
: 0 end
: UNION ALL
: SELECT t.d+ 1, t.n + case when day(t.d +1)%3=0 then 1 else

y****w
发帖数: 3747
37
maxrecursion
http://msdn.microsoft.com/en-us/library/ms181714.aspx

else
else

【在 y****9 的大作中提到】
:
: then
: then
: Learning SQL server now :-) Based on your sql structure; the following
: works in SQL Server 2005
: WITH t(d,n)
: AS ( SELECT getdate(), case when day(getdate())%3=0 then 1 else
: 0 end
: UNION ALL
: SELECT t.d+ 1, t.n + case when day(t.d +1)%3=0 then 1 else

y****w
发帖数: 3747
38
我刚去写了一下那个isbusinessday,这个好像要麻烦多了。可以开个新贴做。

90

【在 B*****g 的大作中提到】
: 木有table。从system date后数N天business day,显示出来。有table就是老问题,90
: %的数据库版SQL问题可以用partition by解决。

B*****g
发帖数: 34098
39
你们先把oracle问题解决,我现在很郁闷。其实我下一个SQL是前100个质数,假设没有
判断质数function

【在 y****w 的大作中提到】
: 我刚去写了一下那个isbusinessday,这个好像要麻烦多了。可以开个新贴做。
:
: 90

y****9
发帖数: 144
40

I asked the below question in Oracle-L, let's if any useful info can be
obtained during weekend.
---
Don't understand why the below query does not give me the next 10 days
instead get past 10 days. ( also noticed without the cast it does not work
at all)
SQL> select * from v$version
2 ;
BANNER
----------------------------------------------------------------------------
----
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
SQL> with t(d,n) as
2 (
3 select cast ( sysdate as date) , 1
4 from dual
5 union all
6 select t.d + 1, t.n +1
7 from t
8 where t.n < 10
9 )
10 select * from t
11 ;
D N
------------------- ----------
2012-01-06 20:35:28 1
2012-01-05 20:35:28 2
2012-01-04 20:35:28 3
2012-01-03 20:35:28 4
2012-01-02 20:35:28 5
2012-01-01 20:35:28 6
2011-12-31 20:35:28 7
2011-12-30 20:35:28 8
2011-12-29 20:35:28 9
2011-12-28 20:35:28 10
10 rows selected.

【在 B*****g 的大作中提到】
: 你们先把oracle问题解决,我现在很郁闷。其实我下一个SQL是前100个质数,假设没有
: 判断质数function

相关主题
请教各位大侠呀.一道题 PL/SQL
oracle help?SQL, recruiter发过来的面试题 (转载)
Oracle 求助urgent: how to compare two dates in SQL?
进入Database版参与讨论
B*****g
发帖数: 34098
41
我也试过了 to_char(to_date(t.d, 'mmddyyyy')+1, 'mmddyyyy'), 同样是递减的

没有

【在 y****9 的大作中提到】
:
: I asked the below question in Oracle-L, let's if any useful info can be
: obtained during weekend.
: ---
: Don't understand why the below query does not give me the next 10 days
: instead get past 10 days. ( also noticed without the cast it does not work
: at all)
: SQL> select * from v$version
: 2 ;
: BANNER

y****w
发帖数: 3747
42
手头没oracle环境。 质数感觉要复杂,每次计算的不是上次增量,

【在 B*****g 的大作中提到】
: 你们先把oracle问题解决,我现在很郁闷。其实我下一个SQL是前100个质数,假设没有
: 判断质数function

v***e
发帖数: 2108
43
从4开始, 先找composite, 一直到N, when N - #of composite = 98
然后{2...N} minus 所有composite

【在 y****w 的大作中提到】
: 手头没oracle环境。 质数感觉要复杂,每次计算的不是上次增量,
y****9
发帖数: 144
44
Got a reply from Oracle-L
------------------------
Looks like you are hitting Bug 11840579 :-) It looks weird, but if you
reference the date column twice it returns the expected data:
SQL> with t(d,n) as
2 (
3 select cast ( sysdate as date) , 1
4 from dual
5 union all
6 select decode(d,null,d,d +1), n+1
7 from t
8 where n<10
9 )
10 select * from t;
D N
--------- ----------
07-JAN-12 1
08-JAN-12 2
09-JAN-12 3
10-JAN-12 4
11-JAN-12 5
12-JAN-12 6
13-JAN-12 7
14-JAN-12 8
15-JAN-12 9
16-JAN-12 10
10 rows selected.
Another discussion on the same problem:
https://forums.oracle.com/forums/thread.jspa?threadID=1055057
Cheers,
Mihajlo
------------------------------------

【在 y****9 的大作中提到】
:
: I asked the below question in Oracle-L, let's if any useful info can be
: obtained during weekend.
: ---
: Don't understand why the below query does not give me the next 10 days
: instead get past 10 days. ( also noticed without the cast it does not work
: at all)
: SQL> select * from v$version
: 2 ;
: BANNER

y****9
发帖数: 144
45

惭愧,看不懂。数学,算法的很差。还是喜欢next N biz day SQL problem.

【在 v***e 的大作中提到】
: 从4开始, 先找composite, 一直到N, when N - #of composite = 98
: 然后{2...N} minus 所有composite

y****w
发帖数: 3747
46

I mean do it with one SQL....

【在 v***e 的大作中提到】
: 从4开始, 先找composite, 一直到N, when N - #of composite = 98
: 然后{2...N} minus 所有composite

B*****g
发帖数: 34098
47
thanks,what is oracle-l?

work

【在 y****9 的大作中提到】
: Got a reply from Oracle-L
: ------------------------
: Looks like you are hitting Bug 11840579 :-) It looks weird, but if you
: reference the date column twice it returns the expected data:
: SQL> with t(d,n) as
: 2 (
: 3 select cast ( sysdate as date) , 1
: 4 from dual
: 5 union all
: 6 select decode(d,null,d,d +1), n+1

y****w
发帖数: 3747
48
l==list, I believe.

【在 B*****g 的大作中提到】
: thanks,what is oracle-l?
:
: work

y****9
发帖数: 144
49

It is a popular mailing list among Oracle DBAs. Some big names like Jonathan
Lewis, Tanel Poder, Cary Millsap etc occasionally answer questions there.
http://www.freelists.org/post/oracle-l/Oracle-11g-CTE-recursive
BTW I just googled a sql that could give all prime numbers within 10000,
will see if it can be adapted to find next N prime number problem if get
some time
http://digitalbush.com/2010/03/16/prime-numbers-as-a-sql-query/

【在 B*****g 的大作中提到】
: thanks,what is oracle-l?
:
: work

B*****g
发帖数: 34098
50
这个oracle论坛帖子一个ACE问,一个ACE direcoter + 一个ACE + 一个Guru(7800点)
答,哈哈。

Jonathan

【在 y****9 的大作中提到】
:
: It is a popular mailing list among Oracle DBAs. Some big names like Jonathan
: Lewis, Tanel Poder, Cary Millsap etc occasionally answer questions there.
: http://www.freelists.org/post/oracle-l/Oracle-11g-CTE-recursive
: BTW I just googled a sql that could give all prime numbers within 10000,
: will see if it can be adapted to find next N prime number problem if get
: some time
: http://digitalbush.com/2010/03/16/prime-numbers-as-a-sql-query/

相关主题
有大侠知道怎么format下面这个query的时间么advices please on learning Oracle
business analyst (SQL) opening in NYCOracle证书
考古了半天,大家说的db developer和一般的programmer有什么Web Seminar hosted by CINAOUG on 2011/06/13
进入Database版参与讨论
y****w
发帖数: 3747
51
这年头用list,newsgroup的人越来越少了。

点)

【在 B*****g 的大作中提到】
: 这个oracle论坛帖子一个ACE问,一个ACE direcoter + 一个ACE + 一个Guru(7800点)
: 答,哈哈。
:
: Jonathan

B*****g
发帖数: 34098
52
我前几天在linkedin上加了10几个group,现在每天都要减少灌水时间去读email。那个
oracle pro没人理我,我也懒的理他们,group太多了

7800

【在 y****w 的大作中提到】
: 这年头用list,newsgroup的人越来越少了。
:
: 点)

y****w
发帖数: 3747
53
I defined some filter, so all linkedin emails will pass the inbox and don't
bother any more. suppose you're also using gmail.

【在 B*****g 的大作中提到】
: 我前几天在linkedin上加了10几个group,现在每天都要减少灌水时间去读email。那个
: oracle pro没人理我,我也懒的理他们,group太多了
:
: 7800

B*****g
发帖数: 34098
54
一天一封,看看他们都在干嘛,一半是招工广告

t
那个

【在 y****w 的大作中提到】
: I defined some filter, so all linkedin emails will pass the inbox and don't
: bother any more. suppose you're also using gmail.

y****9
发帖数: 144
55
Oracle-L is really a very high quality mailing list,especially for Oracle
DBAs, highly recommended if you are an Oracle DBA. I subscribe it with my
working email account, and filter the oracle-l email to a special folder, so
it is easy to follow ( but I only post with my yahoo account). Anyway I
check my working email very often, so it is convenient for me to read Oracle
-L meassage at the same place while reading working emails.

【在 y****w 的大作中提到】
: 这年头用list,newsgroup的人越来越少了。
:
: 点)

v***e
发帖数: 2108
56
I see. 不过这也太坑爹了吧,DBA面试就问这个?
我想Oracle DB group的人也没几个能直接写出来的。

【在 y****w 的大作中提到】
: I defined some filter, so all linkedin emails will pass the inbox and don't
: bother any more. suppose you're also using gmail.

y****w
发帖数: 3747
57
还好吧 会递归不算过份 比如算这个日子 在数据库开发中树结构处理还是很多的
但算质数肯定算变态了 不如封装一个Java或c函数

【在 v***e 的大作中提到】
: I see. 不过这也太坑爹了吧,DBA面试就问这个?
: 我想Oracle DB group的人也没几个能直接写出来的。

1 (共1页)
进入Database版参与讨论
相关主题
怎么准备第一份DBA工作oracle help?
比较sqlplus和sql developerOracle 求助
招db developer, dba (austin tx)一道题 PL/SQL
请问有没有带DBA培训的美国CCSQL, recruiter发过来的面试题 (转载)
SQL Server - convert datetime to a string YY-MM-DD HHurgent: how to compare two dates in SQL?
请帮忙在PL/SQL里面执行下面的计算,一个笔记软件破解用的有大侠知道怎么format下面这个query的时间么
菜鸟请教一个关于oracle里日期的问题business analyst (SQL) opening in NYC
请教各位大侠呀.考古了半天,大家说的db developer和一般的programmer有什么
相关话题的讨论汇总
话题: datepart话题: date话题: sql话题: jan话题: 2012