Home » SQL & PL/SQL » SQL & PL/SQL » substring help
substring help [message #738] Thu, 28 February 2002 15:21 Go to next message
Ravi
Messages: 251
Registered: June 1998
Senior Member
Hi,

How do I eleminated to not to selected when i do following query. I am getting 8 records, but technically I have to get 6 only with the values. Can any body help me ?

create table ravi( a varchar2(10),b varchar2(10),c varchar2(10));
insert into ravi values('100,200','xx,yy','test');
insert into ravi values(null,'aa,bb','test');
insert into ravi values('555,666',null,'test');
insert into ravi values(null,null,null);
insert into ravi values(null,null,'test');

select c,substr(a,1,instr(a,',')-1),substr(b,1,instr(b,',')-1) from ravi
union
select c,substr(a,instr(a,',')+1),substr(b,instr(b,',')+1) from ravi
/
Re: substring help [message #741 is a reply to message #738] Thu, 28 February 2002 22:58 Go to previous messageGo to next message
THA
Messages: 26
Registered: February 2002
Junior Member
use where condition to eliminate the rows for null value
Re: substring help [message #749 is a reply to message #738] Fri, 01 March 2002 09:30 Go to previous message
monir
Messages: 22
Registered: February 2002
Junior Member
try this
select c,substr(a,1,instr(a,',')-1),substr(b,1,instr(b,',')-1) from ravi
where substr(a,1,instr(a,',')-1) is not null
or substr(b,1,instr(b,',')-1) is not null
union
select c,substr(a,instr(a,',')+1),substr(b,instr(b,',')+1) from ravi
where substr(a,1,instr(a,',')+1) is not null
or substr(b,1,instr(b,',')+1) is not null
/
Previous Topic: how do i get a list of all triggers,procedures etc associated with a table
Next Topic: how do i see the trigger description
Goto Forum:
  


Current Time: Fri Apr 19 01:38:31 CDT 2024