Connect by level , help
Could someone help with connect by level. Iam trying to get week ending date for all the projects in the table.
select pid , enddate + 7*level as end_date , level
from
(select enddate(somedate logic from diff tables), t1.pid
from
table1 t1 , table2 t2
where
cobditions...
t1.id = t2.id and t1.pid = '123'
) connect by level <= 4
This logic works for a single project..
If same thing i do for multiple projects, it doesnt seem to work.
for Single Project result is like is
ProjectId Date
123 17-AUG-08
123 24-AUG-08
123 31-AUG-08
123 07-SEP-08
Samething for multiple projects, it results like this
(I use the same qry but don’t send the id there)
ProjectId Date level
123 17-AUG-08 1
123 24-AUG-08 2
123 31-AUG-08 3
123 07-SEP-08 4
125 07-sep-08 4
126 09-sep-08 4
COuld someone help me to how to achieve this for multiple projects.
I am not sure what are you trying to do, but week ending date for a given date can be calculated using NEXT_DAY or TRUNC functions. Issue is "week ending" itself. It is nls dependent. If you want to get client nls specific "week ending" date use:
next_date(given_date-1,7)
SQL> select next_day(sysdate-1,7) week_ending_date,
2 to_char(next_day(sysdate-1,7),'Day') week_ending_day
3 from dual
4 /
WEEK_ENDI WEEK_ENDI
20-SEP-08 Saturday
SQL> alter session set nls_territory=france;
Session altered.
SQL> select next_day(sysdate-1,7) week_ending_date,
2 to_char(next_day(sysdate-1,7),'Day') week_ending_day
3 from dual
4 /
WEEK_END WEEK_ENDI
21/09/08 Sunday
SQL> As you can see, next_date(given_date-1,7) will return nearest Saturday for client in the US and Sunday for a client in France. If you want nls independent solution you could use function TRUNC with IW format. ISO week always starts Monday. So if you consider Saturday as week ending day use:
TRUNC(given_date,'IW') + 6
SQL> alter session set nls_territory=america;
Session altered.
SQL> select trunc(sysdate,'IW') + 5 week_ending_date,
2 to_char(trunc(sysdate,'IW') + 5,'Day') week_ending_day
3 from dual
4 /
WEEK_ENDI WEEK_ENDI
20-SEP-08 Saturday
SQL> alter session set nls_territory=france;
Session altered.
SQL> select trunc(sysdate,'IW') + 5 week_ending_date,
2 to_char(trunc(sysdate,'IW') + 5,'Day') week_ending_day
3 from dual
4 /
WEEK_END WEEK_ENDI
20/09/08 Saturday
SQL> if you consider Sunday as week ending day use:
SQL> alter session set nls_territory=america;
Session altered.
SQL> select trunc(sysdate,'IW') + 6 week_ending_date,
2 to_char(trunc(sysdate,'IW') + 6,'Day') week_ending_day
3 from dual
4 /
WEEK_ENDI WEEK_ENDI
21-SEP-08 Sunday
SQL> alter session set nls_territory=france;
Session altered.
SQL> select trunc(sysdate,'IW') + 6 week_ending_date,
2 to_char(trunc(sysdate,'IW') + 6,'Day') week_ending_day
3 from dual
4 /
WEEK_END WEEK_ENDI
21/09/08 Sunday
SQL> As you can see TRUNC(given_date,'IW') + N is nls independent.
SY.
Similar Messages
-
Can someone explain this to me (connect by level help)
I have this join:
select count(*)
from vchr_line v, vchr_dist t
where
t.VOUCHER_ID = v.VOUCHER_ID and
t.VOUCHER_LINE_NUM = v.VOUCHER_LINE_NUM
connect by level <= 10
When I run this select and there's one row in the vchr_line table that joins with one row in the vchr_dist table the count is 10.
If there are two rows in the vchr_dist table that join with one row in the vchr_line table the count is 2046.
Why is that?I'm really not that good at defining geometric
progressions, writing summation formulas, etc. I
just picked 2 formulas that worked, whether I not
they accurately described the verbage I wrote, I
can't say. so,
1) I'll assume that your equation is better thanHere some examples ( in case of 2 starting rows, your initial formula and mine are the same)
SQL> WITH t AS (SELECT ROWNUM ID FROM tabs WHERE ROWNUM <=3)
2 SELECT COUNT(*), (power(3,6) -3)/(3-1) formula
3 FROM t
4 CONNECT BY LEVEL <=5
5 /
COUNT(*) FORMULA
363 363
SQL>
SQL> WITH t AS (SELECT ROWNUM ID FROM tabs WHERE ROWNUM <=5)
2 SELECT COUNT(*), (power(5,9) -5)/(5-1) formula
3 FROM t
4 CONNECT BY LEVEL <=8
5 /
COUNT(*) FORMULA
488280 488280
mine. although I honestly thought the sigma thing
was close ;-)The sigma thing is precisely correct, here i can only second you ;-)
2) allowing joins in connect bys is a bad thingNot necessarily, it depends only on number of rows in the result of join and how many starting points could be. In this example join doesn't do any harm:
SQL> SELECT COUNT(*)
2 FROM emp e,dept d
3 WHERE e.deptno=d.deptno
4 CONNECT BY PRIOR empno=mgr
5 START WITH mgr IS NULL
6 /
COUNT(*)
14Best regards
Maxim -
SQL Query help ( On connect By level clause)
Hi all,
I have this query developed with data in with clause.
With dat As
select '@AAA @SSS @DDD' col1 from dual union all
select '@ZZZ @XXX @TTT @RRR @ZZA' col1 from dual
Select regexp_substr( col1 , '[^@][A-Z]+',1,level) Show from dat
connect by level <= regexp_count(col1, '@');Current output :-
SHOW
AAA
SSS
DDD
RRR
ZZA
TTT
RRR
ZZA
XXX
DDD
RRR
SHOW
ZZA
TTT
RRR
ZZA
. . .1st row comes fine, But next row data is getting duplicated. And total record count = 30. I tried with some but didn't work.
Expected output :-
SHOW
AAA
SSS
DDD
ZZZ
XXX
TTT
RRR
ZZAI need some change on my query and I am not able to find that. So anybody can add on that or can also provide some different solution too.
Thanks!
AshutoshHi,
When you use something like "CONNECT BY LEVEL <= x", then at least one of the following must be true:
(a) the table has no more than 1 row
(b) there are other conditions in the CONNECT BY clause, or
(c) you know what you are doing.
To help see why, run this query
SELECT SYS_CONNECT_BY_PATH (dname, '/') AS path
, LEVEL
FROM scott.dept
CONNECT BY LEVEL <= 3
;and study the results:
PATH LEVEL
/ACCOUNTING 1
/ACCOUNTING/ACCOUNTING 2
/ACCOUNTING/ACCOUNTING/ACCOUNTING 3
/ACCOUNTING/ACCOUNTING/RESEARCH 3
/ACCOUNTING/ACCOUNTING/SALES 3
/ACCOUNTING/ACCOUNTING/OPERATIONS 3
/ACCOUNTING/RESEARCH 2
/ACCOUNTING/RESEARCH/ACCOUNTING 3
/ACCOUNTING/RESEARCH/RESEARCH 3
/ACCOUNTING/RESEARCH/SALES 3
/ACCOUNTING/RESEARCH/OPERATIONS 3
/ACCOUNTING/SALES 2
/ACCOUNTING/SALES/ACCOUNTING 3
84 rows selected. -
Connect by level query is taking too long time to run
Hello,
I have a query that returns quarters (YYYYQ) of a begin- and enddate within a specific id, that is built with a connect by level clause, but the query is running to long. I have used explain plan to see what the query is doing, but no silly things to see, just a full table scan, with low costs.
This is the query:
select to_char(add_months( cpj.crpj_start_date,3*(level - 1)),'YYYYQ') as sales_quarter
, cpj.crpj_id as crpj_id
from mv_gen_cra_projects cpj
where cpj.crpj_start_date >= to_date('01/01/2009','mm/dd/yyyy')
and cpj.crpj_start_date <= cpj.crpj_end_date
and cpj.crpj_routing_type = 'A'
and ( cpj.crpj_multi_artist_ind = 'N'
or cpj.crpj_multi_artist_ind is null)
connect by level <= 1 + ceil(months_between(cpj.crpj_end_date,cpj.crpj_start_date)/3);
The result have to be like this:
SALES_QUARTER CRPJ_ID
20091 100
20092 100
20093 100
20094 100
20101 100
20102 100
Can anyone help me out with this?but no silly things to see, just a full table scan, with low costs.Well, maybe an index scan would be faster?
However:
You will need to provide us some more details, like:
- database version (the result of: SQL> select * from v$version;)
- post the explain plan output (put the tag before and after it, so indentation and formatting are maintained, see the [FAQ|http://forums.oracle.com/forums/help.jspa] for more explanation regarding tags )
- what are your optimizer settings (the result of: SQL> show parameter optimizer)
- if applicable: are your table statistics up to date?
- mv_gen_cra_projects is a materialized view perhaps?
Edited by: hoek on Jan 26, 2010 10:50 AM -
ORA-01446 Tabular Form with CONNECT BY LEVEL =2
I created a tabular form where I would like the last 2 lines to be blank so the user can enter new rows immediately (e.g., the first time when no data is found).
The following is the sql for the tabular form:
select
"ID",
"REQ_ID",
"QUANTITY",
"FRAME_SIZE",
"FRAME_TYPE",
"PROTECTIVE_COVERING",
"MATT",
"MATT_COLOR"
from "#OWNER#"."CREATIVE_SVC_DESIGN_FRAMING"
union all
select
null id,
null req_id,
null quantity,
null frame_size,
null frame_type,
null protective_covering,
null matt,
null matt_color
from dual
connect by level <= 2 I get the following error:
failed to parse SQL query:
ORA-01446: cannot select ROWID from, or sample, a view with DISTINCT, GROUP BY, etc.
The query is not accessing ROWID from a view at all. And, as you can see, it is not using a DISTINCT, GROUP BY, etc..
My APEX is Application Express 4.0.2.00.07
My Database is 10g (10.2.0.5.0)
Please help!!
Robert
http://apexjscss.blogspot.comRobert,
I wish I had a better explanation for you, but I know something new with 4.1 broke this union trick for tabular forms. I had to make a dynamic action that runs on page load and calls the addRow() javascript function instead. I think it has something to do with tabular form validation but I am not sure.
Cheers,
Tyson Jouglet -
Performance issue with connect by level query
Hi I have a problem with connect by level in oracle.
My table is :
J_USER_CALENDAR
USER_NAME FROM_DATE TO_DATE COMMENTS
Uma Shankar 2-Nov-09 5-Nov-09 Comment1
Veera 11-Nov-09 13-Nov-09 Comment2
Uma Shankar 15-Dec-09 17-Dec-09 Commnet3
Vinod 20-Oct-09 21-Oct-09 Comments4
The above table is the user leave calendar.
Now I need to display the users who are on leave between 01-Nov-2009 to 30-Nov-2009
The output should look like:
USER_NAME FROM_DATE COMMENTS
Uma Shankar 2-Nov-09 Comment1
Uma Shankar 3-Nov-09 Comment1
Uma Shankar 4-Nov-09 Comment1
Uma Shankar 5-Nov-09 Comment1
Veera 11-Nov-09 Comment2
Veera 12-Nov-09 Comment2
Veera 13-Nov-09 Comment2
For this I have tried with following query , but it is taking too long time to execute.
select FROM_DATE,user_name,comments from (SELECT distinct FROM_DATE,user_name ,
comments FROM (SELECT (LEVEL) + FROM_DATE-1 FROM_DATE,TO_DATE, FIRST_NAME||' '|| LAST_NAME
user_name ,COMMENTS FROM J_USER_CALENDAR
where
and J_USER_CALENDAR.IS_DELETED=0
CONNECT BY LEVEL <= TO_DATE - FROM_DATE+1) a )where (FROM_DATE = '01-Nov-2009' or FROM_DATE = '30-Nov-2009'
or FROM_DATE between '01-Nov-2009' and '30-Nov-2009') order by from_Date ,lower(user_name)
Please help me.
Thanks in advance.
Regards,
PhanikanthI have not attempted to analyze your SQL statement.
Here is a test set up:
CREATE TABLE T1(
USERNAME VARCHAR2(30),
FROM_DATE DATE,
TO_DATE DATE,
COMMENTS VARCHAR2(100));
INSERT INTO T1 VALUES ('Uma Shankar', '02-Nov-09','05-Nov-09','Comment1');
INSERT INTO T1 VALUES ('Veera','11-Nov-09','13-Nov-09','Comment2');
INSERT INTO T1 VALUES ('Uma Shankar','15-Dec-09','17-Dec-09','Commnet3');
INSERT INTO T1 VALUES ('Vinod','20-Oct-09','21-Oct-09','Comments4');
INSERT INTO T1 VALUES ('Mo','20-Oct-09','05-NOV-09','Comments4');
COMMIT;Note that I included one additional row, where the person starts their vacation in the previous month and ends in the month of November.
You could approach the problem like this:
Assume that you would like to list all of the days of a particular month:
SELECT
TO_DATE('01-NOV-2009','DD-MON-YYYY')+(ROWNUM-1) MONTH_DAY
FROM
DUAL
CONNECT BY
LEVEL<=ADD_MONTHS(TO_DATE('01-NOV-2009','DD-MON-YYYY'),1)-TO_DATE('01-NOV-2009','DD-MON-YYYY');Note that the above attempts to calculate the number of days in the month of November - if it is known that the month has a particular number of days, 30 for instance, you could rewrite the CONNECT BY clause like this:
CONNECT BY
LEVEL<=30Now, we need to pick up those rows of interest from the table:
SELECT
FROM
T1 T
WHERE
(T.FROM_DATE BETWEEN TO_DATE('01-NOV-2009','DD-MON-YYYY') AND TO_DATE('30-NOV-2009','DD-MON-YYYY')
OR T.TO_DATE BETWEEN TO_DATE('01-NOV-2009','DD-MON-YYYY') AND TO_DATE('30-NOV-2009','DD-MON-YYYY'));
USERNAME FROM_DATE TO_DATE COMMENTS
Uma Shankar 02-NOV-09 05-NOV-09 Comment1
Veera 11-NOV-09 13-NOV-09 Comment2
Mo 20-OCT-09 05-NOV-09 Comments4If we then join the two resultsets, we have the following query:
SELECT
FROM
T1 T,
(SELECT
TO_DATE('01-NOV-2009','DD-MON-YYYY')+(ROWNUM-1) MONTH_DAY
FROM
DUAL
CONNECT BY
LEVEL<=ADD_MONTHS(TO_DATE('01-NOV-2009','DD-MON-YYYY'),1)-TO_DATE('01-NOV-2009','DD-MON-YYYY')) V
WHERE
(T.FROM_DATE BETWEEN TO_DATE('01-NOV-2009','DD-MON-YYYY') AND TO_DATE('30-NOV-2009','DD-MON-YYYY')
OR T.TO_DATE BETWEEN TO_DATE('01-NOV-2009','DD-MON-YYYY') AND TO_DATE('30-NOV-2009','DD-MON-YYYY'))
AND V.MONTH_DAY BETWEEN T.FROM_DATE AND T.TO_DATE
ORDER BY
USERNAME,
MONTH_DAY;
USERNAME FROM_DATE TO_DATE COMMENTS MONTH_DAY
Mo 20-OCT-09 05-NOV-09 Comments4 01-NOV-09
Mo 20-OCT-09 05-NOV-09 Comments4 02-NOV-09
Mo 20-OCT-09 05-NOV-09 Comments4 03-NOV-09
Mo 20-OCT-09 05-NOV-09 Comments4 04-NOV-09
Mo 20-OCT-09 05-NOV-09 Comments4 05-NOV-09
Uma Shankar 02-NOV-09 05-NOV-09 Comment1 02-NOV-09
Uma Shankar 02-NOV-09 05-NOV-09 Comment1 03-NOV-09
Uma Shankar 02-NOV-09 05-NOV-09 Comment1 04-NOV-09
Uma Shankar 02-NOV-09 05-NOV-09 Comment1 05-NOV-09
Veera 11-NOV-09 13-NOV-09 Comment2 11-NOV-09
Veera 11-NOV-09 13-NOV-09 Comment2 12-NOV-09
Veera 11-NOV-09 13-NOV-09 Comment2 13-NOV-09Charles Hooper
IT Manager/Oracle DBA
K&M Machine-Fabricating, Inc. -
Convert Oracle "connect by level 10" into MS SQL server 2005
I want to convert oracle "SELECT LEVEL R FROM CONNECT BY LEVEL <=10" my bottom requirement is get 1 to 10 as a dynamic table inside a query.
Ex: Select id, name, R from names N, (1,2,3,4,5,6,7,8,9,10) R WHERE id < 1000
If any one know something regarding this please reply me.
Thx,
BuddhikaHi Buddhika Jayawardhane ,
Have you sold your problem? I have the same issue to convert from Oracle into SQL Server:
SELECT all_steps.to_step_id step_id, rownum step_order
FROM (
SElECT 0 from_step_id, steps.step_id to_step_id
FROM steps
WHERE steps.is_root = 1
UNION
SElECT step_transitions.from_step_id, step_transitions.to_step_id
FROM step_transitions
) all_steps
CONNECT BY all_steps.from_step_id = PRIOR all_steps.to_step_id
START WITH all_steps.from_step_id = 0
Please help me find information how to make it!
Thanks in advance,
cores -
Is there something I am doing wrong below? I need to generate 9 rows instead of 39. Can someone please help?
Thanks in advance.
Using 10g & 11g
CREATE TABLE V9_MONTHLY (
S_ID VARCHAR2(4),
P_ID VARCHAR2(4),
F_ID VARCHAR2(4),
ELIGIBLE_MONTH DATE,
CONTRACT VARCHAR2(4),
S_ADDRESS_SUFFIX VARCHAR2(1),
REV FLOAT,
EXPENSE FLOAT,
NI FLOAT ) ;
INSERT INTO V9_MONTHLY ( S_ID, P_ID, F_ID, ELIGIBLE_MONTH, CONTRACT, S_ADDRESS_SUFFIX, REV, EXPENSE, NI ) VALUES ( 'S001', 'P001', 'F001', '01-DEC-2009', 'C001', 'B', '300', '200', '100' ) ;
INSERT INTO V9_MONTHLY ( S_ID, P_ID, F_ID, ELIGIBLE_MONTH, CONTRACT, S_ADDRESS_SUFFIX, REV, EXPENSE, NI ) VALUES ( 'S001', 'P001', 'F001', '01-JAN-2010', 'C001', 'B', '100', '1000', '-900' ) ;
INSERT INTO V9_MONTHLY ( S_ID, P_ID, F_ID, ELIGIBLE_MONTH, CONTRACT, S_ADDRESS_SUFFIX, REV, EXPENSE, NI ) VALUES ( 'S001', 'P002', 'F002', '01-FEB-2010', 'C001', 'B', '200', '10000', '-9800' ) ;
( SELECT s_id, p_id, f_id, ADD_MONTHS(ELIGIBLE_MONTH,LEVEL-1) ELIGIBLE_MONTH FROM
( SELECT s_id, p_id, f_id, ELIGIBLE_MONTH
FROM V9_MONTHLY )
CONNECT BY LEVEL <= 3 )could you move your connect by level out and make it its own table
WITH counter AS ( SELECT LEVEL cnt
FROM DUAL
CONNECT BY LEVEL <= 3)
SELECT s_id,
p_id,
f_id,
ADD_MONTHS (ELIGIBLE_MONTH, cnt - 1) ELIGIBLE_MONTH
FROM V9_MONTHLY, counter;
S_ID P_ID F_ID ELIGIBLE_MONTH
S001 P001 F001 12/1/2009
S001 P001 F001 1/1/2010
S001 P002 F002 2/1/2010
S001 P001 F001 1/1/2010
S001 P001 F001 2/1/2010
S001 P002 F002 3/1/2010
S001 P001 F001 2/1/2010
S001 P001 F001 3/1/2010
S001 P002 F002 4/1/2010believe this should work to if you are a fan of the model clause
/* Formatted on 12/10/2010 2:30:51 PM (QP5 v5.149.1003.31008) */
SELECT s_id,
p_id,
f_id,
ELIGIBLE_MONTH
FROM V9_MONTHLY
MODEL
PARTITION BY (s_id, p_id, f_id, ELIGIBLE_MONTH x)
DIMENSION BY (0 d)
MEASURES (eligible_month)
RULES
ITERATE (3)
(eligible_month [ITERATION_NUMBER] =
ADD_MONTHS (eligible_month[0], ITERATION_NUMBER));Edited by: pollywog on Dec 10, 2010 2:38 PM
and again using recursive with
* Formatted on 12/10/2010 3:56:49 PM (QP5 v5.149.1003.31008) */
WITH t ( s_id,
p_id,
f_id,
nbr,
ELIGIBLE_MONTH
) AS
SELECT
s_id,
p_id,
f_id,
1,
ELIGIBLE_MONTH
FROM V9_MONTHLY
UNION /**/ALL
SELECT s_id,
p_id,
f_id,
nbr + 1,
ADD_MONTHS(ELIGIBLE_MONTH, 1) FROM t WHERE nbr <= 2
SELECT S_ID, P_ID, ELIGIBLE_MONTH FROM t
Edited by: pollywog on Dec 10, 2010 3:57 PM -
Inherited some strange code - connect by level
Hello, I've recently read about how "connect by level" can be used to display parent-child relationships but I have inherited this code that appears to use that phrase in a different way.
This is the SQL
select trunc(dt) createdate, 230 eventcode, 1 isholiday
from (
select (trunc(to_date('10/7/2010','mm/dd/yyyy')) + level) dt from dual
connect by level<= 120
where to_char(dt,'dy') in ('sat','sun')
and dt between to_date('10/7/2010','mm/dd/yyyy') and to_date('10/14/2010','mm/dd/yyyy')
This code is supposed to be identifying weekend days between a start and end time with an event code (230) and it seems to work unless I use a weekend date (10/9/2010 or 10/10/2010) as the start time. I also dont understand where the value 120 came from.
Any help would be greatly appreciated.Hi,
user13066820 wrote:
Hello, I've recently read about how "connect by level" can be used to display parent-child relationships but I have inherited this code that appears to use that phrase in a different way.You've described the situation exactly!
CONNECT BY is often used to display recursive parent-child relatioships.
When "LEVEL <= x" is the only CONNECT BY condition, then it's not really doing that; it's just using the recursive power of CONNECT BY to do something else, such as generate the numbers from 1 to 120, or, in this case, generate the 120 dates after a given date. The result set of such a sub-qeury is typically used as a table later in the query, and it's called a Counter Table , because LEVEL is used to count from 1 to x.
This is the SQL
select trunc(dt) createdate, 230 eventcode, 1 isholiday
from (
select (trunc(to_date('10/7/2010','mm/dd/yyyy')) + level) dt from dual
connect by level<= 120
where to_char(dt,'dy') in ('sat','sun')
and dt between to_date('10/7/2010','mm/dd/yyyy') and to_date('10/14/2010','mm/dd/yyyy')
This code is supposed to be identifying weekend days between a start and end time with an event code (230) and it seems to work unless I use a weekend date (10/9/2010 or 10/10/2010) as the start time. LEVEL starts at 1, and increases, so, by adding LEVEL to the given date, the dates generated will all be after the given date.
Usually people want to generate dates on or after a given date, so they subtract 1 from LEVEL.
I also dont understand where the value 120 came from. That makes two of us.
My guess is that someone thought the query would be used for periods of a week or two, as specified in the BETWEEN condition. The programmer may have thought "I probably won't need to generate more than 14 days, but maybe somebody will want a whole month, so I'll make it count up to 31. Aw, heck, I'll make it 120, then they can do a whole quarter, or more."
Any help would be greatly appreciated.Here's how I would write that query:
WITH all_dates AS
SELECT first_date + LEVEL - 1 AS dt
FROM (
SELECT TO_DATE ( '10/07/2010'
, 'MM/DD/YYYY'
) AS first_date
, TO_DATE ( '10/14/2010'
, 'MM/DD/YYYY'
) AS last_date
FROM dual
CONNECT BY LEVEL <= 1 + last_date - first_date
SELECT dt
, 230 AS eventcode
, 1 AS isweekend
FROM all_dates
WHERE TO_CHAR ( dt
, 'Dy'
, 'NLS_DATE_LANGUAGE=ENGLISH'
) IN ('Sat', 'Sun')
;The first_date parameter only has to be hard-coded once, and that date is included in the results.
Notice the CONNECT BY clause is now gererating only the rows it might need, not some arbitrary number of rows, most of which will probably be eliminated by a WHERE clause later on. The use of first_date and last_date makes the code self-documenting, but there's no reason you can't add claifying comments as well.
Edited by: Frank Kulash on Mar 11, 2011 3:17 PM -
Oracle 10.1 + connect by level
Hi all,
Coul you help me to tune this request please ?
select
count(seq)
from (select rownum as seq
from dual
connect by level <=
select max(substr(filename, 22, 4))
from thufitab A
where A.received > to_date('24/07/2013', 'DD/MM/YY') - 1
and A.filename like 'NA0061%'))
where seq >= (select min(substr(filename, 22, 4))
from thufitab A
where A.received > to_date('24/07/2013', 'DD/MM/YY') - 1
and A.filename like 'NA0061%')
and seq not in (select distinct substr(filename, 22, 4)
from thufitab A
where A.received > to_date('24/07/2013', 'DD/MM/YY') - 1
and A.filename like 'NA0061%');
Thanks a lot.Hi,
Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), so that the people who want to help you can re-create the problem and test their ideas.
Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
Post the exact code you're running.
See the forum FAQ: https://forums.oracle.com/message/9362002#9362002
I think your query can be re-written like this:
WITH universe AS
SELECT SUBSTR (filename, 22, 4) AS num
FROM thufitab
WHERE received > TO_DATE ('24/07/2013', 'DD/MM/YYYY')
AND filename LIKE 'NA0061%'
AND LENGTH (filename) >= 22
, extrema AS
SELECT MIN (num) AS min_num
, MAX (num) AS max_num
FROM universe
SELECT COUNT (*) AS missing_cnt
FROM extrema
WHERE min_num + LEVEL NOT IN (
SELECT num
FROM universe
CONNECT BY LEVEL <= max_num - min_num
Of course, unless you post some sample data and results, I can't test it.
Once you have a query that produces the right results, see this other page from the forum FAQ:
https://forums.oracle.com/message/9362003 -
I just got the new ipod touch (5th generation) and it will show up on my computer but it will not show up on itunes and it won't connect. Please help!
See:
iOS: Device not recognized in iTunes for Windows
You need iTunes version 10.7 -
APEX - 4
DB version - 10g
Web server architecture - OHS
Browser - IE8
Theme - 5
I know how to set and display help text for a page item, and I see there is the option to add help text at the page level, but how does the user accessing the screen see the page level help text?
I was thinking it might be a good way to add user help guide information at the page level.
Thank you for any assistance.I know how to set and display help text for a page item, and I see there is the option to add help text at the page level, but how does the user accessing the screen see the page level help text?Using a Help page and region accessed via a help link (e.g. a navigation bar entry), or using the <tt>apex_application.help</tt> API method in a PL/SQL Dynamic Content region.
This is covered in the APEX documentation which should be consulted before posting a question here. -
while updating my ipad to new software through itunes it got stuck and does not work anymore - it just displays the screen with symbols of itunes and the cable to connect to it - help - what should i do?
Disconnect the iPad, do a Reset [Hold the Home and Sleep/Wake buttons down together for 10 seconds or so (until the Apple logo appears) and then release. The screen will go blank and then power ON again in the normal way.] It is 'appsolutely' safe!, reconnect and follow the prompts.
If that does not work then see here http://support.apple.com/kb/HT1808 -
I have problem with my ipad , when i want to update ios 6 to 6.0.1 this message appear " unable to verify update , ios 6.0.1 faild verification because you are no longer connected to the internet" but my ipad is connected . Plz help me .
Not very helpful but I have the same issue. Plugging in and doing the update via. iTunes will probably work but I find that whole experience annoying (downloading apps not on the Mac, etc..)
-
I need help my computer isn't working and there is no was to get on my iTunes and I just updated my phone and now it's stuck on where it shows the plug connected to iTunes help!!!!
There is no other way than to plug into a computer to restore the phone. You can use another computer to do so, but in case you did not back up to iCloud your data and settings will be gone.
Follow this article to connect in recovery mode:
iOS: Unable to update or restore
Maybe you are looking for
-
IPhone-iTunes stuck while installing 5.0
Good morning, I just prepared everything to install the 5.0 version of the software on my iPhone 3GS. While doing the job, iTunes and iPhone just got stuck, nothing is moving on and I have the Apple and a partial bar on the iPhone's screen and a part
-
Where can I download flash builder burrito standard preview release?
Dear all, Where can I download the flash builder burrito? My current project is in burrito and I want to set up for my new pc but still can't find the archive of Burrito version and when I downloaded the latest version of flash builder 4.5 it can't r
-
Standard sql statement v/s parameterized statement
Are standard sql statements more effiecient that parameterized sql statements (in former case binding happens at compile time and latter at run time?) standard sql statement : stmt->executeUpdate("INSERT INTO basket_tab VALUES(`MANGOES', 3)"); parame
-
hi i have just installed os x 10.4.6 tiger. everything went fine whilst installing but now i cant use itunes as it is saying needs 10.4.7 or higher, so i run a softwear update and i am able to select "mac os x update (combined) powerpc 10.4.10 170MB"
-
How to view all procedures from commandprompt
Hai All, we have query select * from tab; in oracle to view all tabels in database.Like this how can we view all procedures