Query substring and not numeric
Using Oracle 10g.
I need help with a query.. I need to get all the values where the first character is not a number. I know how to get the first character but other than that I'm lost.
SELECT * FROM my_table where substr(EMP_ID, 1,1) is not numeric?
Hi,
user9179751 wrote:
Using Oracle 10g.
I need help with a query.. I need to get all the values where the first character is not a number. I know how to get the first character but other than that I'm lost.
SELECT * FROM my_table where substr(EMP_ID, 1,1) is not numeric?Here's one way:
SELECT *
FROM my_table
WHERE INSTR ( '0123456789'
, SUBSTR (emp_id, 1, 1)
) = 0
;Regular expressions and the LIKE operator can also do the job, perhaps with a little less coding, but they'll probably be less efficient. They can be very powerful tools, but you don't want to pay for that power when you're not using it.
Similar Messages
-
How to replace null value, if column is text and not numeric in OBIEE?
Hi,
Please note that I had tried to change the null text by adding bin value for Unspecified and Unknown but this did not work for me.. not sure if I am missing out to put anything in value filter…
Thank You,
RaviCheck this function:
http://docs.oracle.com/cd/E23943_01/bi.1111/e10544/appsql.htm#CHDHJABI
Cheers
Nico
IFNULL
This function tests if an expression evaluates to a null value, and if it does, assigns the specified value to the expression.
Syntax
IFNULL(expr, value)
Where:
expr is the expression to evaluate.
value is the value to assign if the expression evaluates to a null value. -
Why substring and not subString?
why is it that "substring" doesn't have a second capital S? every OTHER not-first word gets to be capitalized.
this is just a programming practice you however could write a class with SUBSTRING in all caps. no compil;ation or runtime errors/
-
Query slow and contention Oracle RAC
Hi,
I have problems with our BD...
I have a query that takes a long time and freeze...
our BD is Oracle 10.2.0.4 on RAC with 2 nodes over Red Hat Enterprise Linux Server release 5.3, 64G RAM CPU
SGA : sga_max_target=16G sga__target=15G
db_4k_cache_size=4G , keep=800M , default =10G in mode automatic
return results of the ADDM says:
ACTION: Investigate the SQL statement with SQL_ID "bb9bma7du62h3" for possible performance improvements.
RELEVANT OBJECT: SQL statement with SQL_ID bb9bma7du62h3 and PLAN_HASH 2145292722
SELECT X.DOCDOCUMENTOID, X.DOCNUMERODOCSERVICIO, X.DOCFECHADOCSERVICIO, X.DOCFECHADOCCGR, IDEN.ISEGLOSANOMBRE, X.SCGDESCRIPCION, MAT.MDODESCRIPCION, TIP.TDODESCRIPCION, X.DESNUMEROCASOS, X.DESESTADO, X.DESSECCIONID, X.DESUSERID, X.TIMESTAMP, X.TSTAMP, IDENREP.ISEGLOSANOMBRE AS REPARTICION, X.NOMOBSERVACION
FROM
( SELECT DOC.DOCDOCUMENTOID, DOC.DOCNUMERODOCSERVICIO, DOC.DOCFECHADOCSERVICIO, DOC.DOCFECHADOCCGR, SEC.SCGDESCRIPCION, DES.DESNUMEROCASOS, DES.DESESTADO, DES.DESSECCIONID, DES.DESUSERID, DOC.TIMESTAMP, DES.TIMESTAMP AS TSTAMP, NOM.NOMOBSERVACION, DOC.DOCREPARTICIONID, DOC.DOCSERVICIOID,DOC.DOCTIPODOCUMENTO, DOC.DOCMATERIAINGRESO
FROM
TBLDOCESTUDIO DES,
TBLDOCUMENTO DOC, TBLSECCIONCGR SEC,TBLNOMINA NOM
WHERE 1 = 1
AND :B7 = DES.DESESTADO
AND :B6 = DES.DESSECCIONID
AND DOC.DOCDOCUMENTOID = DES.DESDOCUMENTOID
AND DES.DESSECCIONID = SEC.SCGCODIGO
AND NOM.NOMNOMINAID = DES.DESNOMINAACTIVA
AND DES.DESNUMEROCASOS BETWEEN :B5 AND :B4
AND NOM.NOMNRONOMINA BETWEEN :B3 AND :B2
AND DOC.DOCNUMERODOCSERVICIO LIKE :B1 ) X,
TBLTIPODOCUMENTO TIP,
TBLMATERIADOCUMENTO MAT,
TBLIDENTIFICACIONSERVICIO IDEN,
TBLIDENTIFICACIONSERVICIO IDENREP
WHERE 1=1
AND X.DOCMATERIAINGRESO = MAT.MDOCODIGO
AND X.DOCTIPODOCUMENTO = TIP.TDOCODIGO
AND X.DOCSERVICIOID = IDEN.ISESERVICIOID
AND X.DOCREPARTICIONID = IDENREP.ISESERVICIOID
AND ROWNUM < :B8RATIONALE: SQL statement with SQL_ID "bb9bma7du62h3" was executed 155 times and had an average elapsed time of 283 seconds.
RATIONALE: Waiting for event "direct path read temp" in wait class "User I/O" accounted for 19% of the database time spent in processing the SQL statement with SQL_ID "bb9bma7du62h3".
RATIONALE: Waiting for event "enq: TS - contention" in wait class "Other" accounted for 8% of the database time spent in processing the SQL statement with SQL_ID "bb9bma7du62h3".
RATIONALE: Waiting for event "direct path write temp" in wait class "User I/O" accounted for 4% of the database time spent in processing the SQL statement with SQL_ID "bb9bma7du62h3".
RATIONALE: Average CPU used per execution was 78 seconds.
We have table TBLDOCUMENTO with 4K tablespaces.
We have indexes of TBLDOCUMENTO in other tablespaces with 8K
segments TBLLDOCUMENTO have size of 3,5G
Any ideas how to solve "direct path read temp" , "enq: TS - contention" , "direct path write temp"
and how to make the query faster and not hang
sorry for my bad english...
Regards..
Mario
Edited by: user1056867 on 07-09-2011 12:21 PMDBMS_SQLTUNE.REPORT_TUNING_TASK('SIAPER')
GENERAL INFORMATION SECTION
Tuning Task Name : Siaper
Tuning Task Owner : SYSTEM
Scope : COMPREHENSIVE
Time Limit(seconds) : 60
Completion Status : COMPLETED
Started at : 09/08/2011 10:18:04
Completed at : 09/08/2011 10:18:55
Number of SQL Profile Findings : 1
Schema Name: SIAPER3
SQL ID : bb9bma7du62h3
SQL Text : SELECT X.DOCDOCUMENTOID, X.DOCNUMERODOCSERVICIO,
X.DOCFECHADOCSERVICIO, X.DOCFECHADOCCGR, IDEN.ISEGLOSANOMBRE,
X.SCGDESCRIPCION, MAT.MDODESCRIPCION, TIP.TDODESCRIPCION,
X.DESNUMEROCASOS, X.DESESTADO, X.DESSECCIONID, X.DESUSERID,
X.TIMESTAMP, X.TSTAMP, IDENREP.ISEGLOSANOMBRE AS REPARTICION,
X.NOMOBSERVACION FROM ( SELECT DOC.DOCDOCUMENTOID,
DOC.DOCNUMERODOCSERVICIO, DOC.DOCFECHADOCSERVICIO,
DBMS_SQLTUNE.REPORT_TUNING_TASK('SIAPER')
DOC.DOCFECHADOCCGR, SEC.SCGDESCRIPCION, DES.DESNUMEROCASOS,
DES.DESESTADO, DES.DESSECCIONID, DES.DESUSERID, DOC.TIMESTAMP,
DES.TIMESTAMP AS TSTAMP, NOM.NOMOBSERVACION,
DOC.DOCREPARTICIONID, DOC.DOCSERVICIOID , DOC.DOCTIPODOCUMENTO,
DOC.DOCMATERIAINGRESO FROM TBLDOCESTUDIO DES, TBLDOCUMENTO DOC,
TBLSECCIONCGR SEC, TBLNOMINA NOM WHERE 1 = 1 AND :B7 =
DES.DESESTADO AND :B6 = DES.DESSECCIONID AND DOC.DOCDOCUMENTOID
= DES.DESDOCUMENTOID AND DES.DESSECCIONID = SEC.SCGCODIGO AND
NOM.NOMNOMINAID = DES.DESNOMINAACTIVA AND DES.DESNUMEROCASOS
BETWEEN :B5 AND :B4 AND NOM.NOMNRONOMINA BETWEEN :B3 AND :B2 AND
DOC.DOCNUMERODOCSERVICIO LIKE :B1 ) X, TBLTIPODOCUMENTO TIP,
TBLMATERIADOCUMENTO MAT, TBLIDENTIFICACIONSERVICIO IDEN,
TBLIDENTIFICACIONSERVICIO IDENREP WHERE 1=1 AND
X.DOCMATERIAINGRESO = MAT.MDOCODIGO AND X.DOCTIPODOCUMENTO =
TIP.TDOCODIGO AND X.DOCSERVICIOID = IDEN.ISESERVICIOID AND
X.DOCREPARTICIONID = IDENREP.ISESERVICIOID AND ROWNUM < :B8
FINDINGS SECTION (1 finding)
DBMS_SQLTUNE.REPORT_TUNING_TASK('SIAPER')
1- SQL Profile Finding (see explain plans section below)
A potentially better execution plan was found for this statement.
Recommendation (estimated benefit<=10%)
- Consider accepting the recommended SQL profile.
execute dbms_sqltune.accept_sql_profile(task_name => 'Siaper', replace =>
TRUE);
EXPLAIN PLANS SECTION
1- Original With Adjusted Cost
Plan hash value: 3376565491
| Id | Operation | Name | Ro
DBMS_SQLTUNE.REPORT_TUNING_TASK('SIAPER')
ws | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | |
1 | 246 | 34 (3)| 00:00:01 |
|* 1 | COUNT STOPKEY | |
| | | |
|* 2 | FILTER | |
| | | |
|* 3 | HASH JOIN | |
1 | 246 | 34 (3)| 00:00:01 |
| 4 | TABLE ACCESS FULL | TBLTIPODOCUMENTO |
32 | 608 | 2 (0)| 00:00:01 |
| 5 | NESTED LOOPS | |
1 | 227 | 32 (4)| 00:00:01 |
| 6 | NESTED LOOPS | |
1 | 182 | 31 (4)| 00:00:01 |
|* 7 | HASH JOIN | |
1 | 137 | 30 (4)| 00:00:01 |
| 8 | NESTED LOOPS | |
1 | 113 | 27 (0)| 00:00:01 |
DBMS_SQLTUNE.REPORT_TUNING_TASK('SIAPER')
| 9 | NESTED LOOPS | |
1 | 75 | 26 (0)| 00:00:01 |
| 10 | NESTED LOOPS | |
16 | 688 | 2 (0)| 00:00:01 |
| 11 | TABLE ACCESS BY INDEX ROWID| TBLSECCIONCGR |
1 | 29 | 1 (0)| 00:00:01 |
|* 12 | INDEX UNIQUE SCAN | PK_TBLSECCIONCGR |
1 | | 1 (0)| 00:00:01 |
| 13 | TABLE ACCESS BY INDEX ROWID| TBLNOMINA |
16 | 224 | 1 (0)| 00:00:01 |
|* 14 | INDEX RANGE SCAN | IDX_IDX_NOM_NRONOMINA |
1 | | 1 (0)| 00:00:01 |
|* 15 | TABLE ACCESS BY INDEX ROWID | TBLDOCESTUDIO |
1 | 32 | 2 (0)| 00:00:01 |
|* 16 | INDEX RANGE SCAN | IDX_DESNOMINA |
1 | | 1 (0)| 00:00:01 |
|* 17 | TABLE ACCESS BY INDEX ROWID | TBLDOCUMENTO |
1 | 38 | 1 (0)| 00:00:01 |
|* 18 | INDEX UNIQUE SCAN | PK_TBLDOCUMENTO |
1 | | 1 (0)| 00:00:01 |
| 19 | TABLE ACCESS FULL | TBLMATERIADOCUMENTO |
DBMS_SQLTUNE.REPORT_TUNING_TASK('SIAPER')
47 | 1128 | 2 (0)| 00:00:01 |
| 20 | TABLE ACCESS BY INDEX ROWID | TBLIDENTIFICACIONSERVICIO |
1 | 45 | 1 (0)| 00:00:01 |
|* 21 | INDEX UNIQUE SCAN | PK_TBLIDENTIFICACIONSERVICIO |
1 | | 1 (0)| 00:00:01 |
| 22 | TABLE ACCESS BY INDEX ROWID | TBLIDENTIFICACIONSERVICIO |
1 | 45 | 1 (0)| 00:00:01 |
|* 23 | INDEX UNIQUE SCAN | PK_TBLIDENTIFICACIONSERVICIO |
1 | | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter(ROWNUM<TO_NUMBER(:B8))
2 - filter(:B3<=:B2 AND :B5<=:B4)
3 - access("DOC"."DOCTIPODOCUMENTO"="TIP"."TDOCODIGO")
7 - access("DOC"."DOCMATERIAINGRESO"="MAT"."MDOCODIGO")
12 - access("SEC"."SCGCODIGO"=:B6)
14 - access("NOM"."NOMNRONOMINA">=:B3 AND "NOM"."NOMNRONOMINA"<=:B2)
DBMS_SQLTUNE.REPORT_TUNING_TASK('SIAPER')
15 - filter("DES"."DESSECCIONID"=:B6 AND "DES"."DESESTADO"=:B7 AND "DES"."DESN
UMEROCASOS">=:B5 AND
"DES"."DESNUMEROCASOS"<=:B4)
16 - access("NOM"."NOMNOMINAID"="DES"."DESNOMINAACTIVA")
filter("DES"."DESNOMINAACTIVA">=0)
17 - filter("DOC"."DOCNUMERODOCSERVICIO" LIKE :B1)
18 - access("DOC"."DOCDOCUMENTOID"="DES"."DESDOCUMENTOID")
21 - access("DOC"."DOCSERVICIOID"="IDEN"."ISESERVICIOID")
23 - access("DOC"."DOCREPARTICIONID"="IDENREP"."ISESERVICIOID")
2- Using SQL Profile
Plan hash value: 2086638886
| Id | Operation | Name | Ro
ws | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | |
DBMS_SQLTUNE.REPORT_TUNING_TASK('SIAPER')
1 | 246 | 31 (0)| 00:00:01 |
|* 1 | COUNT STOPKEY | |
| | | |
|* 2 | FILTER | |
| | | |
| 3 | NESTED LOOPS | |
1 | 246 | 31 (0)| 00:00:01 |
| 4 | NESTED LOOPS | |
1 | 201 | 30 (0)| 00:00:01 |
| 5 | NESTED LOOPS | |
1 | 156 | 29 (0)| 00:00:01 |
| 6 | NESTED LOOPS | |
1 | 132 | 28 (0)| 00:00:01 |
| 7 | NESTED LOOPS | |
1 | 113 | 27 (0)| 00:00:01 |
| 8 | NESTED LOOPS | |
1 | 75 | 26 (0)| 00:00:01 |
| 9 | NESTED LOOPS | |
16 | 688 | 2 (0)| 00:00:01 |
| 10 | TABLE ACCESS BY INDEX ROWID| TBLSECCIONCGR |
1 | 29 | 1 (0)| 00:00:01 |
DBMS_SQLTUNE.REPORT_TUNING_TASK('SIAPER')
|* 11 | INDEX UNIQUE SCAN | PK_TBLSECCIONCGR |
1 | | 1 (0)| 00:00:01 |
| 12 | TABLE ACCESS BY INDEX ROWID| TBLNOMINA |
16 | 224 | 1 (0)| 00:00:01 |
|* 13 | INDEX RANGE SCAN | IDX_IDX_NOM_NRONOMINA |
1 | | 1 (0)| 00:00:01 |
|* 14 | TABLE ACCESS BY INDEX ROWID | TBLDOCESTUDIO |
1 | 32 | 2 (0)| 00:00:01 |
|* 15 | INDEX RANGE SCAN | IDX_DESNOMINA |
1 | | 1 (0)| 00:00:01 |
|* 16 | TABLE ACCESS BY INDEX ROWID | TBLDOCUMENTO |
1 | 38 | 1 (0)| 00:00:01 |
|* 17 | INDEX UNIQUE SCAN | PK_TBLDOCUMENTO |
1 | | 1 (0)| 00:00:01 |
| 18 | TABLE ACCESS BY INDEX ROWID | TBLTIPODOCUMENTO |
1 | 19 | 1 (0)| 00:00:01 |
|* 19 | INDEX UNIQUE SCAN | PK_TBLTIPODOCUMENTO |
1 | | 1 (0)| 00:00:01 |
| 20 | TABLE ACCESS BY INDEX ROWID | TBLMATERIADOCUMENTO |
1 | 24 | 1 (0)| 00:00:01 |
|* 21 | INDEX UNIQUE SCAN | PK_TBLMATERIADOCUMENTO |
DBMS_SQLTUNE.REPORT_TUNING_TASK('SIAPER')
1 | | 1 (0)| 00:00:01 |
| 22 | TABLE ACCESS BY INDEX ROWID | TBLIDENTIFICACIONSERVICIO |
1 | 45 | 1 (0)| 00:00:01 |
|* 23 | INDEX UNIQUE SCAN | PK_TBLIDENTIFICACIONSERVICIO |
1 | | 1 (0)| 00:00:01 |
| 24 | TABLE ACCESS BY INDEX ROWID | TBLIDENTIFICACIONSERVICIO |
1 | 45 | 1 (0)| 00:00:01 |
|* 25 | INDEX UNIQUE SCAN | PK_TBLIDENTIFICACIONSERVICIO |
1 | | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter(ROWNUM<TO_NUMBER(:B8))
2 - filter(:B3<=:B2 AND :B5<=:B4)
11 - access("SEC"."SCGCODIGO"=:B6)
13 - access("NOM"."NOMNRONOMINA">=:B3 AND "NOM"."NOMNRONOMINA"<=:B2)
14 - filter("DES"."DESSECCIONID"=:B6 AND "DES"."DESESTADO"=:B7 AND "DES"."DESN
UMEROCASOS">=:B5 AND
DBMS_SQLTUNE.REPORT_TUNING_TASK('SIAPER')
"DES"."DESNUMEROCASOS"<=:B4)
15 - access("NOM"."NOMNOMINAID"="DES"."DESNOMINAACTIVA")
filter("DES"."DESNOMINAACTIVA">=0)
16 - filter("DOC"."DOCNUMERODOCSERVICIO" LIKE :B1)
17 - access("DOC"."DOCDOCUMENTOID"="DES"."DESDOCUMENTOID")
19 - access("DOC"."DOCTIPODOCUMENTO"="TIP"."TDOCODIGO")
21 - access("DOC"."DOCMATERIAINGRESO"="MAT"."MDOCODIGO")
23 - access("DOC"."DOCREPARTICIONID"="IDENREP"."ISESERVICIOID")
25 - access("DOC"."DOCSERVICIOID"="IDEN"."ISESERVICIOID")
1 row selected. -
Using MODEL clause and COUNT for not numeric data columns....
Hi ,
Is it possible somehow to use the COUNT function to transform a non-numeric data column to a numeric data value (a counter) and be used in a MODEL clause....????
For example , i tried the following in the emp table of SCOTT dataschema with no desired result...
SQL> select deptno , empno , hiredate from emp;
DEPTNO EMPNO HIREDATE
20 7369 18/12/1980
30 7499 20/02/1981
30 7521 22/02/1981
20 7566 02/04/1981
30 7654 28/09/1981
30 7698 01/05/1981
10 7782 09/06/1981
20 7788 18/04/1987
10 7839 17/11/1981
30 7844 08/09/1981
20 7876 21/05/1987
30 7900 03/12/1981
20 7902 03/12/1981
10 7934 23/01/1982
14 rows selected Now , i want to use the MODEL clause in order to 'predict' the number of employees who were going to be hired in the 1990 per deptno...
So , i have constructed the following query which , as expected, does not return the desired results....
SQL> select deptno , month , year , count_
2 from
3 (
4 select deptno , to_number(to_char(hiredate,'mm')) month ,
5 to_number(to_char(hiredate , 'rrrr')) year , count(ename) count_
6 from emp
7 group by deptno , to_number(to_char(hiredate,'mm')) ,
8 to_number(to_char(hiredate , 'rrrr'))
9 )
10 model
11 partition by(deptno)
12 dimension by (month , year)
13 measures (count_ )
14 (
15 count_[1,1990]=count_[1,1982]+count_[11,1982]
16 )
17 /
DEPTNO MONTH YEAR COUNT_
30 5 1981 1
30 12 1981 1
30 2 1981 2
30 9 1981 2
30 1 1990
20 4 1987 1
20 5 1987 1
20 4 1981 1
20 12 1981 1
20 12 1980 1
20 1 1990
10 6 1981 1
10 11 1981 1
10 1 1982 1
10 1 1990 As you see , the measures for the 1990 year is null...because the measure(the count(deptno)) is computed via the group by and not by the MODEL clause...
How should i transform the above query... so as the "count_[1,1982]+count_[11,1982]" will return non-null results per deptno...????
Thanks , a lot
SimonConnected to Oracle Database 10g Express Edition Release 10.2.0.1.0
Connected as hr
SQL>
SQL> SELECT department_id, MONTH, YEAR, count_
2 FROM (SELECT e.department_id
3 ,to_number(to_char(e.hire_date, 'mm')) MONTH
4 ,to_number(to_char(e.hire_date, 'rrrr')) YEAR
5 ,COUNT(e.first_name) count_
6 FROM employees e
7 WHERE e.department_id = 20
8 GROUP BY e.department_id
9 ,to_number(to_char(e.hire_date, 'mm'))
10 ,to_number(to_char(e.hire_date, 'rrrr')));
DEPARTMENT_ID MONTH YEAR COUNT_
20 8 1997 1
20 2 1996 1
SQL> --
SQL> SELECT department_id, MONTH, YEAR, count_
2 FROM (SELECT e.department_id
3 ,to_number(to_char(e.hire_date, 'mm')) MONTH
4 ,to_number(to_char(e.hire_date, 'rrrr')) YEAR
5 ,COUNT(e.first_name) count_
6 FROM employees e
7 WHERE e.department_id = 20
8 GROUP BY e.department_id
9 ,to_number(to_char(e.hire_date, 'mm'))
10 ,to_number(to_char(e.hire_date, 'rrrr')))
11 model
12 PARTITION BY(department_id)
13 dimension BY(MONTH, YEAR)
14 measures(count_)(
15 count_ [1, 1990] = count_ [2, 1996] + count_ [8, 1997]
16 );
DEPARTMENT_ID MONTH YEAR COUNT_
20 8 1997 1
20 2 1996 1
20 1 1990 2
SQL> ---
SQL> SELECT department_id, MONTH, YEAR, count_
2 FROM (SELECT e.department_id
3 ,to_number(to_char(e.hire_date, 'mm')) MONTH
4 ,to_number(to_char(e.hire_date, 'rrrr')) YEAR
5 ,COUNT(e.first_name) count_
6 FROM employees e
7 GROUP BY e.department_id
8 ,to_number(to_char(e.hire_date, 'mm'))
9 ,to_number(to_char(e.hire_date, 'rrrr')))
10 model ignore nav
11 PARTITION BY(department_id)
12 dimension BY(MONTH, YEAR)
13 measures(count_)(
14 count_ [1, 1990] = count_ [2, 1996] + count_ [8, 1997]
15 );
DEPARTMENT_ID MONTH YEAR COUNT_
100 8 1994 2
30 12 1997 1
100 3 1998 1
30 7 1997 1
5 1999 1
30 12 1994 1
30 11 1998 1
30 5 1995 1
100 9 1997 2
100 12 1999 1
30 8 1999 1
1 1990 0
30 1 1990 0
100 1 1990 0
90 9 1989 1
20 8 1997 1
70 6 1994 1
93 rows selected
SQL> -
Minus and - not working in query
Hi all,
I am operating on 10G R/2.
I have thsi query where thi sstatement <pre>(COUNT(W_O) - COUNT(W_I))</pre> TOTAL is returning 0.Why is the minus and '-' not working out in this query?.
<Pre>
SELECT
TRUNC(DT) week_start ,
next_day (TRUNC( DT) - 7, 'Sunday' ) + 6 week_end ,
to_number(to_char(DT,'FMWW'))wk_no ,
'I_'||W_I AS IO ,
COUNT(W_I) TOTAL
FROM TABLE_A
WHERE W_I IS NOT NULL
GROUP BY TRUNC(DT),
next_day (TRUNC( DT) - 7, 'Sunday' ) + 6,
to_number(to_char(DT,'FMWW')),
'I_'||W_I
UNION ALL
SELECT
TRUNC(DT) week_start ,
next_day (TRUNC( DT) - 7, 'Saturday' ) + 6 week_end ,
to_number(to_char(DT,'FMWW'))wk_no ,
'O_'||W_O AS IO,
(COUNT(W_O) - COUNT(W_I)) TOTAL
FROM TABLE_A
WHERE W_O IS NOT NULL
GROUP BY
TRUNC(DT),
to_number(to_char(DT,'FMWW')), 'O_'||W_O
</pre>
Edited by: CrackerJack on Jun 14, 2011 8:06 PMbasic maths
SQL> select count(object_name), count(owner), count(object_name) - count(owner)
2 from all_objects;
COUNT(OBJECT_NAME) COUNT(OWNER) COUNT(OBJECT_NAME)-COUNT(OWNER)
52658 52658 0
1 row selected.if you take away a number from itself you will get zero. I think you may mean SUM() rather than COUNT() -
After recent upgrade to Yosemite on Macbook air bluetooth audio cuts out and associated video stops with audio. Likewise with airplay and Apple TV. I have deleted all my saved wifi connections and restarted numerous times. I do not expect a resolution from the community, but hope to get the attention of Apple engineers. If you are having same problems or have a miracle cure I am all ears.
May start my own thread, but I'm having similar issues.
I've been using an old iMac (running 10.7.5) and Apple TV for years with no issues. Last week I bought a new Macbook Pro running Yosemite and have had audio issues multiple times. The weird thing is that sometimes it works flawlessly, other times (like now) I spend half an hour just trying to get a song to play.
My issues are: When I got to "computers" in Apple TV to stream my music, my music is sometimes chopper or intermittent, and I seen to know when it's going to happen based on the status wheel just before it plays. When I choose a song, the status wheel will spin for an unusually long time, usually an indicator that the audio is either not going to work, or stutter.
When it does finally pull up a song, the playhead sits at the beginning of the song for a good 3-5 seconds before actually playing. Then, when it starts playing, it's all downhill. It will play a few seconds, drop out, play a few more seconds, drop out, and then ultimately the playhead will keep moving across the song as if it's playing, but there's no audio.
Again, this is a new phenomenon never experienced by me. I've tried everything I could think of, some of them all at once:
• restart Apple TV
• restart Macbook Pro
• quite iTunes/open
• turn off Home Sharing on iTunes then reconnect it
• unplugging and cycling both my modem and router
None of these have alleviated the problem.
The odd thing is, like this morning, the audio started up perfectly and never gave me any issues. It wasn't until later in the day that it started. Perhaps after the macbook pro had been put to sleep? Not sure.
Regardless, this is an annoying trait, one that's new to me and my system (as stated, worked flawlessly until my new purchase), and is 100% limited to either a) the macbook pro b) Yosemite or c) both of them. -
Alv output to Excel with numeric fields as numeric fields only and not char
Hi,
When we download the alv output to excel format in the locat file using the toolbar button provided in the ALV, the numeric fields get converted to character format. Is there any other way or settings in ALV so that the numeric fields will be get saved as numeric fields only and not character?
Rgds,
MAdhuriany idea for above problem is welcome
-
SuccessFactors and DataServices: Query &UNSPECIFIED_NAME was not found in data flow
Fellow Techies--
How do I debug an error like this in data services? I am using the SuccessFactors adapter as the source and sql server tables as the target. The queries to bring the data over are straightforward. Validation claims there are no errors. What am I looking for in this case?Hi Paula and Manoj,
Thanks for writing this post. I was facing similar issue and this was the only post on the subject. I was getting the same error while validating the job. I was not able to trace the reason for the same. Now, I know that the error occured due to CORRUPTION. I am current work, we are facing lots of performance issue due to limitations of the server hardware. We restart the server once a day to resolve performance issues. One such restart must have corrupted my work.
What I did was:
STEP 01: unckeck the box under FROM clause of Query transform and then validate the job. There were some new errors.
STEP02: Check the box again and validate. BINGO !! The error was gone.
Hope the post will help other is future too. -
Lookup-table and query-database do not use global transaction
Hi,
following problem:
DbAdapter inserts data into DB (i.e. an invoice).
Process takes part in global transaction.
After the insert there is a transformation which uses query-database and / or lookup-table.
It seems these XPath / XSLT functions are NOT taking part in the transaction and so we can not access information from the current db transaction.
I know workarounds like using DbAdapter for every query needed, etc. but this will cost a lot of time to change.
Is there any way to share transaction in both DbAdapter insert AND lookup-table and query-database?
Thanks, Best Regards,
MartinOne dba contacted me and made this statement:
Import & export utilities are not independent from characterset. All
user data in text related datatypes is exported using the character set
of the source database. If the character sets of the source and target
databases do not match a single conversion is performed.So far, that does not appear to be correct.
nls_characterset = AL32UTF8
nls_nchar_characterset = UTF8
Running on Windows.
EXP produces a backup in WE8MSWIN1252.
I found that if I change the setting of the NLS_LANG registry setting for my oracle home, the exp utility exports to that character set.
I changed the nls_lang
from AMERICAN_AMERICA.WE8MSWIN1252
to AMERICAN_AMERICA.UTF8
Unfortunately , the export isn't working right, although it did change character sets.
I get a warning on a possible character set conversion issue from AL32UTF8 to UTF8.
Plus, I get an EXP_00056 Oracle error 932 encountered
ORA-00932: inconsistent datatypes: expected BLOB, CLOB, get CHAR.
EXP-00000: export terminated unsuccessfully.
The schema I'm exporting with has exactly one procedure in it. Nothing else.
I guess getting a new error message is progress. :)
Still can't store multi-lingual characters in data tables. -
SuPM - Data from SAP BW Query(Automatic) and Manual not displayed in KPI
Dear Forum,
I am also, currently working on a project implementing BO SuPM Version 1.0. Landscape is ECC -> BI -> SuPM dashboards.
I have created a KPI in SuPM dashboard.
Case 1 : Automatic data collection - This KPI is marked for Automatic data collection. So, maintained Scripts with Connectivity and SAP BW Query name. I save this KPI and include in a new report and Run it. There are no records displayed.
Case 2: Manual data collection - This KPI is marked for manual data collection. So, maintained values in SuPM portal itself. I save this KPI and include in a new report and Run it. There are no records displayed.
Could you please help me how KPI in SuPM be filled manually and automatically ( from BW Query)?
Thanks,
Best Regards
PhaniRajDear Phani,
First of All, you should have a framework created and assign the Core KPI to that framework and specify the frequency of the framework (Say Monthly) and Activate it.
Upon Activation, if it is a Manual Data Collection, then you should perform Role Assignment ie specifyinfwho would be the Business Contributor & Approver for ur Manual KPI.
After this, you have to run this program [/SRCORE/DATAREQUEST] in SE38 in the backend system which wil create a data request,
Later you should login as Business Contributor and go to MY Data Requests and then provide the data for the Month specified. Then login as Approver and under Approvals option, you should Approve the data. Now, you should go to SuPM application and select that Month in the dimension and KPI and then RUN the Report.
For Automated Data Collection, you should have to initially creata a Query (SAP/ BW) and specify the name of the query in SPRO--> Sustainability Performance Management --> Automated Data Collection --> Maintain Queries (SAP/ BW) --> Specify that Query name and the Connector ID (SM59).
Now go for KPI creation and specify the Query name in the KPI and then Assign the KPI to the framework and activate it.
Upon Activation, You should RUN the program /SRCORE/AUTO_DATA_COLLECT. Now, select this KPI in the report and RUN the report.
If you perform these actions, you will get the values in the report.
It can be checked in the backend application, either by checking the Process chain[RSPC] or by checking the Infocube if the data is loaded into the Infocube or not.
Let me know if you face any problems...
Regards,
Raghu -
Infoareas do not at Query Designer and Analyzer
Dear frieds,
We are do not see the infoareas at Query designer and analyzer ( BW Quality ), in DEV is all right, what's happening ?
OBS: The user autority is equal in all clients.
Thanks.
FabrícioHi,
Are you not able to see any of the info areas or only some specific infoareas?
Regards
Akhan -
Web Template not impacted after query changed and Transported
Hi. All.
We have modified the query and transported to production But query changes not been
impacted on Standard web teplate. But it works fine in Bex Analyzer.
Issue is there was a description was truncated earlier we used initially as short description.
Later we mapped to Medium description and modified the entire flow and loaded. It works fine.
Only in production we are not seeing correct description in web report and it works fine with Analyzer. So we need to ask the user as after executing the report he needs to change characterstic property from Standard to Medium.
But it would be bit inconvenience to users.
So how can we solve this problem and why the query changes are not impacting on Web template.
Please provide your views on this issue.
Thanks & Regards
VijayHi Vijay,
one reason might be if you use the option "personalization" within the web template. If users can personalize the templates changes will not be visible and have to be deleted at the time a new version of the query is provided. There are background tables for the personalization as well where you can delete all objects for this template at once if necessary.
Brgds,
Marcel -
Need a record from second query which is not a part of main query.
I have this Query which Leads me to two Rwos of Data
select papf.employee_number E_CODE
,to_char(paaf1.effective_start_date,'DD-MON-RRRR') EFFECTIVE_START_DATE
,DECODE(to_char(paaf1.effective_end_date,'DD-MON-RRRR'),'31-DEC-4712',NULL,to_char(paaf1.effective_end_date,'DD-MON-RRRR')) EFFECTIVE_END_DATE
,TRIM(SUBSTR(PAAF1.ASS_ATTRIBUTE21,INSTR(PAAF1.ASS_ATTRIBUTE21,'-')+1)) PREVIOUS_CO
from apps.per_all_assignments_f paaf
,apps.per_all_people_f papf
,apps.per_grades pg
,apps.per_jobs pj
,apps.per_person_types ppt
,apps.per_person_type_usages_f pptuf
,apps.per_all_assignments_f paaf1
where 1=1
and papf.person_id = paaf.person_id
and pptuf.person_id = papf.person_id
and pptuf.person_type_id = ppt.person_type_id
and ppt.user_person_type = 'Employee'
and papf.current_employee_flag ='Y'
and paaf.primary_flag = 'Y'
and paaf1.primary_flag = 'Y'
and paaf1.grade_id = pg.grade_id
and paaf1.job_id = pj.job_id
and trunc(sysdate) between papf.effective_start_date and papf.effective_end_date
and trunc(sysdate) between pptuf.effective_start_date and pptuf.effective_end_date
and papf.person_id = paaf1.person_id
and (TRIM(UPPER(paaf1.ass_attribute24)) <> TRIM(UPPER(paaf.ass_attribute24))
OR TRIM(UPPER(paaf1.ass_attribute21)) <> TRIM(UPPER(paaf.ass_attribute21))
OR TRIM(UPPER(paaf1.ass_attribute22)) <> TRIM(UPPER(paaf.ass_attribute22))
OR TRIM(UPPER(paaf1.ass_attribute25)) <> TRIM(UPPER(paaf.ass_attribute25))
OR TRIM(UPPER(paaf1.ass_attribute23)) <> TRIM(UPPER(paaf.ass_attribute23))
OR paaf1.grade_id <> paaf.grade_id)
and paaf1.effective_end_date = paaf.effective_start_date - 1
and papf.employee_number in ('10620')
and paaf1.effective_start_date >= '01-JAN-1950'
---------------------------OUT PUT-----------------------------
E_CODE EFFECTIVE_START_DATE EFFECTIVE_END_DATE PREVIOUS_CO
Row1 10620 17-SEP-2009 30-NOV-2009 CORPORATE
Row2 10620 19-NOV-2007 31-JAN-2008 CORPORATE
Problem is enire output of the query is perfectly fine but in the second row at column effective_start_date insted of 19-NOV-2007 in need a value from another query. there must not be any change in rest of the columns data including first row.
i.e select ORIGINAL_DATE_OF_HIRE from per_all_people_f
where employee_number = '10620'
and rownum < 2
---------------------------OUT PUT----------------------------
15-MAY-2006
Is there is any approach to get this thing.
Thanks in advance
Bachan.
Edited by: Bachan on Sep 20, 2010 8:17 PMmaybe a union for your second row.
select E_CODE,
EFFECTIVE_START_DATE,
EFFECTIVE_END_DATE,
PREVIOUS_CO
from (select rownum rn,
papf.employee_number E_CODE
,to_char(paaf1.effective_start_date,'DD-MON-RRRR') EFFECTIVE_START_DATE
,DECODE(to_char(paaf1.effective_end_date,'DD-MON-RRRR'),'31-DEC-4712',NULL,to_char(paaf1.effective_end_date,'DD-MON-RRRR')) EFFECTIVE_END_DATE
,TRIM(SUBSTR(PAAF1.***_ATTRIBUTE21,INSTR(PAAF1.***_ATTRIBUTE21,'-')+1)) PREVIOUS_CO
from apps.per_all_assignments_f paaf
,apps.per_all_people_f papf
,apps.per_grades pg
,apps.per_jobs pj
,apps.per_person_types ppt
,apps.per_person_type_usages_f pptuf
,apps.per_all_assignments_f paaf1
where 1=1
and papf.person_id = paaf.person_id
and pptuf.person_id = papf.person_id
and pptuf.person_type_id = ppt.person_type_id
and ppt.user_person_type = 'Employee'
and papf.current_employee_flag ='Y'
and paaf.primary_flag = 'Y'
and paaf1.primary_flag = 'Y'
and paaf1.grade_id = pg.grade_id
and paaf1.job_id = pj.job_id
and trunc(sysdate) between papf.effective_start_date and papf.effective_end_date
and trunc(sysdate) between pptuf.effective_start_date and pptuf.effective_end_date
and papf.person_id = paaf1.person_id
and (TRIM(UPPER(paaf1.***_attribute24)) TRIM(UPPER(paaf.***_attribute24))
OR TRIM(UPPER(paaf1.***_attribute21)) TRIM(UPPER(paaf.***_attribute21))
OR TRIM(UPPER(paaf1.***_attribute22)) TRIM(UPPER(paaf.***_attribute22))
OR TRIM(UPPER(paaf1.***_attribute25)) TRIM(UPPER(paaf.***_attribute25))
OR TRIM(UPPER(paaf1.***_attribute23)) TRIM(UPPER(paaf.***_attribute23))
OR paaf1.grade_id paaf.grade_id)
and paaf1.effective_end_date = paaf.effective_start_date - 1
and papf.employee_number in ('10620')
and paaf1.effective_start_date >= '01-JAN-1950'0
where rn = 1
union all
select employee_number E_CODE,
ORIGINAL_DATE_OF_HIRE,
EFFECTIVE_END_DATE,
TRIM(SUBSTR(PAAF1.***_ATTRIBUTE21,INSTR(PAAF1.***_ATTRIBUTE21,'-')+1)) PREVIOUS_CO
from per_all_people_f
where employee_number = '10620'
and rownum < 2note: untested -
An Average of a Count erroneously returns integers and not decimals
I have a table which holds sales information showing the invoice number and the branch (e.g. 'New York', 'Boston', etc..) that sold the items. Each row represents a product on an invoice. I am trying to find out the average number of lines per invoice
for each branch. So my final result set might tell me that the 'New York' invoices had an average of 2.4 lines per invoice and the 'Boston' invoices had an average of 1.9 lines per invoice. Like this:
New York, 2.4
Boston, 1.9
I've first written a subquery that counts the number of lines for each BRANCH & INVOICE combination for any date after 1/1/2015. Then I've put a query around that subquery which averages this count by Branch. The problem is, the entire query is only
returning integers and not decimals. Why is this?
Note that I tried casting the data type to DECIMAL and FLOAT but still get the same results.
Here is the query:
Select t1.Branch, cast(avg(t1.Count) as numeric(10,2))
as Avg_Lines
from
(Select Branch, invoice, count(*) as Count
from linprm
where invdte>20150101
group by Branch, invoice) t1
group by t1.BranchTo expand Scott's answer:
Select t1.Branch, avg(cast(t1.Count as numeric(10,2)))
as Avg_Lines
from
(Select Branch, invoice, count(*) as Count
from linprm
where invdte>20150101
group by Branch, invoice) t1
group by t1.Branch
-- or
Select t1.Branch, cast(avg(t1.Count) as numeric(10,2))
as Avg_Lines
from
(Select Branch, invoice, cast(count(*) as numeric(10,2)) as Count
from linprm
where invdte>20150101
group by Branch, invoice) t1
group by t1.Branch
Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com
Maybe you are looking for
-
Safari quits or freezes when I input text into a login field
Hello Everyone, Heres the problem: Whenever I input text into some login fields (on pages I have been using for a long time w/ no previous problems), the app usually freezes, sometimes it quits. I have scoured the forums for people with the same prob
-
I can't scan to my computer with my HP Photosmart Plus B2010a, I get a "Failed to open a session on the device" message everytime. I'm using the most current driver for OS X Lion 10.7 off the HP website.
-
Hi, I have been experiencing some seriously annoying AE problems. I'm experiencing these exact same issues on both: - iMac osx 10.9.4 3.2GHz Intel Core i5 processor - 8GB 1600 MHz DDR3 memory - Macbook Pro osx 10.9.4 2GHz Intel Core i& processor - 1
-
MSI GX623 - Turbo mode in Windows Seven 64 bit
Hello everybody, I have long struggled with "Turbo" on the GX623 laptop in 64bit system. Finally I did the following: 1st I installed the Windows 7 64bit professional 2nd I downloaded: http://eu.msi.com/index.php?func=downloadfile&dno=11356&type=util
-
Hi Guru's is there any way i can create a user who can see only one application in EAS. rest all application should not be visible to that user and only admin can see all the other application in EAS. thank you