Compare non numeric data using arithmetic operations
Hi
Is there anyway to compare the non numeric data in a table to a numeric number.
Want to run a query like
SELECT rank_id
FROM mas_rank
WHERE rank_code > 26 Rank_code contains numeric as well as some non numeric data
Thanx for the help
Yes, it will work if you just say > '26' See this demo :
SQL> create table mas_rank(rank_id number,rank_code varchar2(2));
Table created.
SQL> insert into mas_rank values (100,'aa');
1 row created.
SQL> insert into mas_rank values (101,'ab');
1 row created.
SQL> insert into mas_rank values (102,'ad');
1 row created.
SQL> insert into mas_rank values (103,'ag');
1 row created.
SQL> insert into mas_rank values (104,'ac');
1 row created.
SQL> insert into mas_rank values (105,'22');
1 row created.
SQL> insert into mas_rank values (106,'25');
1 row created.
SQL> insert into mas_rank values (107,'26');
1 row created.
SQL> insert into mas_rank values (108,'27');
1 row created.
SQL> insert into mas_rank values (109,'aa');
1 row created.
SQL> insert into mas_rank values (110,'28');
1 row created.
SQL> SELECT rank_id
2 FROM mas_rank
3 WHERE rank_code not in ('ab','ad','ag')
4 and rank_code > 26;
and rank_code > 26
ERROR at line 4:
ORA-01722: invalid number
SQL> ed
Wrote file afiedt.buf
1 SELECT rank_id
2 FROM mas_rank
3 WHERE rank_code not in ('ab','ad','ag')
4* and rank_code > '26'
SQL> /
RANK_ID
100
104
108
109
110
SQL>Regards
Girish Sharma
Similar Messages
-
Hi,
Why Essbase database can store only "numeric" data is there any workaround to store "non-numeric" data in EssbaseTo expand on this, an analytical view of such data is questionable. While you could aggregate/consolidate and even analyze non-numeric (i.e. categorical responses), the business needs of such analysis are almost always better served with more appropriate tools.
Compare this with regions, time, accounts -- where the structure of the database has an inherent consolidation or mathematical relationship. Deriving value from these numeric relationships is where multidimension analysis thrives.
With text information, you would need to create artificial relationships for the different "values" that at best represent weighted values, not completely useless but again, the right tool would do you better. It seems to me like another case of using a hammer to pound a screw in because the screw driver is still in the tool box.
Some over-eager (read: young) essbase developers love to throw the database logs into essbase cubes, too -- which is rather silly to me (if they don't have enough to keep them busy answering the user's needs, perhaps they should look for additional users...). The two issues have one thing in common: allowing the technology to dictate effort, rather than responding to a business need with targeted solutions.
Hmmm, maybe I'll create a cube to store the number of added members by dimension and the database statistics across time so I can prove to my boss that I'm wasting enough time on boondoggles every day. Well, at least THAT data is numeric...
The above was all said tongue in cheek -- you can use oddball things like this to answer some interesting questions. I just think that if you have questions like that, you should go talk to the CFO and finance departments a bit more to see what kind of questions you COULD be answering. -
How do I import non-numeric data into DIAdem?
I have some non-numeric data in an Excel file which I would like to import into DIAdem. DIAdem recognizes the file and imports some of the data, but it only imports those cells that are purely numeric. Cells containing non-numeric characters are ignored. But I need that non-numeric data! How do I force DIAdem to import everything? (Some controls appear in the import dialog that seem like they might be useful here but they're greyed out.)
Hi There,
You can not load text columns from ASCII files into DIAdem 8.1 DATA channels (numbers only). But the ASCII Import Wizard will let you send those text values to either a separate ASCII file, which DIAdem can use to put them on a graph as labels, or to a DIAdem string array, which DIAdem can use to display them at various places in its environment.
The below attachments demonstrate reading an ASCII text column into a DIAdem string array and displaying the values on a DIAdem table in GRAPH. Note that the index values of the string array are placed in a DIAdem DATA channel.
Ask if you have further questions,
Brad Turpin
NI
Attachments:
ASCII_Text_Column.txt 1 KB
ASCII_Text_Column.STP 1 KB
ASCII_Text_Column.LPD 3 KB -
Is it possible to upload non-numeric data into Planning from ODI?
Dear All,
I have problem to upload non-numeric data into planning?
Regards,
ThomasI am not sure what that has to do with non-numeric data and planning.
If you want to move your ODI environment then have a look at this post :- Re: move full ODI environment to another Machine...
Cheers
John
http://john-goodwin.blogspot.com/ -
Testing for non-Numeric Data in a varchar2
Hello -
What is the easiest way to test see if there is non-numeric data in a varchar2 column? The column holds ssn values, but I am unable to convert these values to numeric data, because somewhere the column is storing non-numeric data.
Thanks in advance.Maybe something like this ?
SQL> create or replace function test_num (var1 in varchar2) return varchar2
2 is
3 num number;
4 begin
5 num := to_number (var1);
6 return ('Number');
7 exception
8 when others then
9 return ('Character');
10* end;
SQL> /
Function created.
SQL> select test_num ('111') from dual;
TEST_NUM('111')
Number
SQL> select test_num ('aaa') from dual;
TEST_NUM('AAA')
Character
SQL> -
Typecasting String to Date using as operator
Typecasting String to Date using as operator
I am doing -
dateId.text as Date;
but it returns null;
How should I typecast String to Date in particular format
like "MM/DD/YYYY""MBhatt" <[email protected]> wrote in
message
news:gnlh6f$5gs$[email protected]..
> Typecasting String to Date using as operator
>
> I am doing -
>
> dateId.text as Date;
>
> but it returns null;
>
> How should I typecast String to Date in particular
format like
> "MM/DD/YYYY"
Date has a parse method, and I think DateField has methods
for this. -
Hi,
I have to check the data in Varchar2 field idtr and if it is numeric some actions are to be done on the data and if it is numeric some other different action is to be done.
So I used some logic for finding whether the data is numeric or non numeric which I got it from the net.
Now my problem is all decimal numbers are to be treated as numeric but this logic is treating decimals as non numeric and I am not able to proceed further.
Can some one help me out in this issue.
Below is the Logic and actions I am doing
select pol_id,lpad(substr(trunc(to_number(idtr),0),1,10),10,0),idtr
from pl_insrd
where length(idtr) - length(translate(idtr,chr(1)||translate(idtr,CHR(1)||'1234567890',CHR(1) ),CHR(1) ) ) = 0
and length(idtr) > 9
UNION
select pol_id,lpad(trunc(idtr,0),10,0),idtr
from pl_insrd
where length(idtr) - length(translate(idtr,chr(1)||translate(idtr,CHR(1)||'1234567890',CHR(1) ),CHR(1) ) ) = 0
and length(idtr) < 10
UNION
select pol_id,substr(idtr,1,10),idtr
from pl_insrd
where length(idtr) - Length(TRANSLATE(idtr,CHR(1)||TRANSLATE(idtr,CHR(1)||'1234567890', CHR(1) ), CHR(1) ) ) > 0
and length(idtr) > 9
UNION
select pol_id,lpad(idtr,10,0),idtr
from pl_insrd
where length(idtr) - Length(TRANSLATE(idtr,CHR(1)||TRANSLATE(idtr,CHR(1)||'1234567890', CHR(1) ), CHR(1) ) ) > 0
and length(idtr) < 10<quote>One I provided was I found at asktom.oracle.com</quote>
So? ... If you'd provided a link then one could see the entire context for that particular snippet of code and decide if it is indeed appropriate. As shown by Angus it is not always appropriate ... add to that, NULL is not a number as that function reports.
<quote>It's using replace and transalate functions which are less expensive then To_Number function.</quote>
Proof?
<quote>I agree with you [John], that's the best function you can use to validate data for numeric.<quote>
I don't agree to_number() is [always] the best way ... the easiest way? ... maybe.
My personal view is that there is no universal way to determine if a string, in all circumstances, can be translated into a number. One has to have knowledge of the source data domain ... only you know if, in your particular circumstance, '1e4' is or is not a NUMBER represented as a string.
flip@FLOP> select to_number('1e3') from dual;
TO_NUMBER('1E3')
1000 -
Getting non numeric strings using regular expression
Hi Guys ,
I want to get list of string values in table which contains no numeric values .....
I have a string column name A and table name B .
I have written following code , but it seems it is incorrect .
Plz help me out .....
SELECT
A FROM
B
WHERE
regexp_like(A, '([^[:digit:]])'
Thanks in advance ....96097f0e-f165-463a-a0a2-3d15214c8a3d wrote:
Hi Guys ,
I want to get list of string values in table which contains no numeric values .....
I have a string column name A and table name B .
I have written following code , but it seems it is incorrect .
Plz help me out .....
SELECT
A FROM
B
WHERE
regexp_like(A, '([^[:digit:]])'
Thanks in advance ....
That will give you every one that has at least one non-numeric character, if you want ones which contain no numeric characters then it should be
regexp_like(A,'^[^0-9]*$') -
Hi,
I'm trying to check our HR phone number table for phone numbers which contain anything except numbers and spaces.
Using sample data:
WITH sampledata AS
(SELECT '01234 123456' col FROM DUAL UNION ALL
SELECT '01234 123456 (Ext 456)' FROM DUAL UNION ALL
SELECT '01234 123213234 (** 2342)' FROM DUAL)
SELECT *
FROM sampledata;I'd like to use SQL to find the 2nd and 3rd examples (and any other rows where the telno does NOT contain just numbers and spaces).
I've tried:
adding a WHERE:
WHERE NOT REGEXP_INSTR(col,'[0-9]') > 0Or this:
where regexp_like(col, '[^[0-9]]*')But when I try that, all rows are returned, presumably because all rows contain numbers.
I'm not sure how to change to return lines which contain both numeric and alphanumeric data, but where spaces are ignored (i.e. if row1 in e.g. above is okay, rows 2 and 3 aren't).
Any advice much appreciated.
Thanks20100511 wrote:
Or this:
where regexp_like(col, '[^[0-9]]*')But when I try that, all rows are returned, presumably because all rows contain numbers.You missed the space: where regexp_like(col, '[^[0-9] ]*')bye
TPD -
Report totals for non-numerical data
Hello all,
I am trying to update a site for an auto shop. The site is in PHP, MySQL.
What they have in the database is records for each customer that comes in to their shop. So, they will have John Q. Public having multiple entries for the date he came in, and what was done to the car. They want a report that will display the totals for each item that John Public has had done.
So for example the report would be displaying the following:
breaks oil change shocks tune up total visits
John Public 2 4 0 2 8
Jack Private 1 6 4 8 19
The database has this information in it to get the above report:
Name Date Work Cust. Review
John Public 02-05-2007 breaks satisfied
John Public 03-15-2008 breaks satisfied
John Public 01-09-2008 oil change satisfied
Is there a way to do this?Well, I have done a lot of playing around, and got it to work. Although, I don't completely understand why it works. If someone would be kind enough to give me some insight, I would greatly appreciate it. I have not done JOINS in the past, so I'm trying to learn.
This is what I had originally:
<?php
//Query the unique works to generate the headers
$query = "SELECT DISTINCT reason FROM `call_log` ORDER BY reason";
$result = mysql_query($query) or die(mysql_error());
while($record = mysql_fetch_assoc($result))
$reasons[] = $record['reason'];
//Start the report table including headers
$report = "<table width=\"75%\" cellpadding=\"5\" cellspacing=\"5\" border=\"1\">\n";
$report .= " <tr><th>Store</th><th>" . implode('</th><th>', $reasons) . "</th></tr>\n";
//Query the records
$query = "SELECT t2.location, t2.reason, COUNT(t1.reason) as total
FROM (
SELECT tt1.location, tt2.reason
FROM (SELECT DISTINCT location FROM `call_log`) tt1,
(SELECT DISTINCT reason FROM `call_log`) tt2) t2
LEFT JOIN `call_log` t1
ON t1.location = t2.location AND t1.reason = t2.reason
GROUP BY t2.reason, t2.location
ORDER BY t2.location, t2.reason";
$result = mysql_query($query) or die(mysql_error());
And this is what I changed it to:
<?php
//Query the unique works to generate the headers
$query = "SELECT DISTINCT call_log.reason, call_reason.reason_id, call_reason.reason
FROM call_log LEFT JOIN call_reason
ON call_log.reason = call_reason.reason_id
ORDER BY call_log.reason";
$result = mysql_query($query) or die(mysql_error());
while($record = mysql_fetch_assoc($result))
$reasons[] = $record['reason'];
// Query to get the top headers to have the correct column span
$query = "SELECT COUNT(*) AS reason_id FROM call_reason";
// Execute Query for the correct column span
$result = mysql_query($query);
// Get the result of query named count
$count = mysql_result($result,0);
//Start the report table including subheaders for the reason totals
$report = "<table width=\"75%\" cellpadding=\"5\" cellspacing=\"5\" border=\"1\">\n";
$report .= " <tr><th style=\"border-color:#000;\">Store</th><th colspan=\"$count\" style=\"border-color:#000;\">Reasons for the Call</th></tr>\n";
$report .= " <tr><th></th><th>" . implode('</th><th>', $reasons) . "</th></tr>\n";
//Query the records
$query = "SELECT t2.location, t2.reason, COUNT(t1.reason) as total
FROM (
SELECT tt1.location, tt2.reason
FROM (SELECT DISTINCT location FROM `call_log`) tt1,
(SELECT DISTINCT reason FROM `call_log`) tt2) t2
LEFT JOIN `call_log` t1
ON t1.location = t2.location AND t1.reason = t2.reason
GROUP BY t2.reason, t2.location
ORDER BY t2.location, t2.reason";
$result = mysql_query($query) or die(mysql_error());
It's the first section of:
$query = "SELECT DISTINCT call_log.reason, call_reason.reason_id, call_reason.reason
FROM call_log LEFT JOIN call_reason
ON call_log.reason = call_reason.reason_id
ORDER BY call_log.reason";
$result = mysql_query($query) or die(mysql_error());
while($record = mysql_fetch_assoc($result))
$reasons[] = $record['reason'];
that I'm wodering about. Since I didn't realize that I defined the vairable for call_reason.reason how did it know to display the data from that field? I know I joined the tables, but why would it not display the call_reason.reason_id?
Thank you very much. -
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> -
Data Storage in Essbase -- Non Numeric
Hi Experts,
Could you please guide me how the non numeric data is stored in Essbase (which is not metadata). Ex: Dates, Text Etc...
It it Essbase first convert date format into numeric and then store or something else???
Thanks
N KumarFrom version 11, Essbase provides some support for text and date measures natively.
Text measures allow a predefined set of text values to be mapped to a predefined set of numeric values - there is no native support for loading 'free text'. The text measure 'mappings' are stored in the Essbase outline (.otl), but for both text and date cases the value itself is stored numerically, like any other data cell.
You can also use formats to convert numeric values to text when reporting. Again, Essbase 'really' only stores data as numbers.
Check out the following page from the latest Database Administrators Guide, which covers all these topics: http://download.oracle.com/docs/cd/E17236_01/epm.1112/esb_dbag/frameset.htm?dtypmeas.html
Edited by: TimG on Jul 8, 2010 5:30 AM
John got there before me. Still, follow the link to the DBAG! -
SQL Tool to insert/update/delete non english data
I have a requirement to insert/update non English data using command line.
I know that Sql*Plus cannot be used for this. I have tried Sql*Loader and that works fine for inserts.
Question is can SQL*loader be used for updates and deletes too.
Also which utility is the best one to be used in this scenario.In another forum I found out that SQL*Plus can actually be used for inserting unicode data.
Re: Sql script not able to insert unicode data in table -
I need to find the next non holiday date for a set of rows in table.I have a separate table where all holidays are listed.Please help me to find the next non holiday date using decode function.
Holiday Table sructure:
create table holiday(no number,holidaydate date);
insert into holiday values(1,to_date('17-AUG-2013','dd/mm/yyyy');
insert into holiday values(1,to_date('05-SEP-2013','dd/mm/yyyy');
I have a code which seems to be wrong.
select decode (lapsedate ,
laps.holidaydate , DECODE
(lapsedate +1,
laps.holidaydate + 1, DECODE
(lapsedate + 2,
laps.holidaydate
+ 2, lapsedate
+ 3,
lapsedate + 2
lapsedate + 1
lapsedate
) from dt;Hi,
Here's one way to do that with your current tables:
WITH cntr AS
SELECT LEVEL AS n
FROM dual
CONNECT BY LEVEL <= 4 -- longest possible distance to next work day
SELECT m.ndate
, m.ndate + MIN (c.n) AS next_work_day
FROM mycalendar m
CROSS JOIN cntr c
LEFT OUTER JOIN holiday h ON h.holidaydate = m.ndate + c.n
WHERE h.holidaydate IS NULL
AND TO_CHAR ( m.ndate + c.n
, 'Dy'
, 'NLS_DATE_LANGUAGE=ENGLISH' -- If needed (but never hurts)
) NOT IN ('Sat', 'Sun')
GROUP BY m.ndate
ORDER BY m.ndate
This assumes that the next work day (that is, non-holiday, Monday through Friday) will be within the next 4 days (which is true where I work). You may need to change the magic number in cntr (4, above) depending on your holidays.
Instead of a holiday table with 1 row per holiday, consider having a calendar table, with 1 row per day, regardless of whether the day is a holiday, weekend or work day. You can have a next_work_day column in the table (populated by a query similar to the one above). It will be more efficient in the long run, and will make coding individual queries much simpler. -
SAP XI 2, JDBC Inbound Adapter. Non Unicode data problem.
Hi All,
As far a I understand the data from inbout JDBC adapter in XI 2 should be in Unicode format. Is it possible to accept non unicode data using this adapter? If answer is yes then how to specify correct data encoding?
Best Regards.
Victor.Hi,
Yes, tecnicaly XMB is aware of the encoding and not the adapter, but when you read data from file you can tell to the adapter that file is in specific encoding e.g. file.encoding = "ISO-8859-5"
This value is used by adapter to create xml file wich is passed to XMB. By default the passed XML is UTF8 encoded.
So I need similar setting for JDBC adapter and my question is if I can do it?
Best Regards.
Victor.
Maybe you are looking for
-
Ipod recognized as a camera, please help
I have seen many similar problems that people have had, let me list everything I have tried so far. Re-installed Itunes as told to by uninstalling every part of it (didnt work) updated my driver for my "Apple mobile device USB driver" as told here ht
-
Alternate rows with different number of columns in JTable or similar
Hi Guys, I have tried searching google and these forums, but have not been able to find what I am looking for. Looking for ideas, on how to do the following I have a swing application, that I would like to have alternate rows eg. 1st row has 10 colum
-
Where can I find the critical iTunes files/settings -- transferring data to new HD
Hi -- I recently installed a new internal Seagate 1TB SSHD drive into my MBP 15" Late 2011 to replace the OEM 500GB internal HD. Did a clean install with OS X Recovery. So far so good. But I didn't transfer over the iTunes settings + whatever file
-
Hi, I am working on BPC 7.5NW SP03. When I try to select the member from MEASURE dimension, I can see only PERIODIC, QTD and YTD. I do not see MTD measure. Can anyone let me know if MTD measure is SAP provided measure OR we need to customize it? How
-
Is there any hope that the constant crashing will be fixed? Every single time I visit certain websites, (kotaku for example) safari crashes if I try to adjust the page size using pinch or zoom. Is this ever going to be recognized or fixed?