I do not seem to have exactly understood
u r problem..........but try this anyway
select count(*)
from a
where l_id in (
select b.bl_id
from a,b
where a.o_id = 17
and a.o_id = b.bo_id )
OR
(a.o_id = 17)
from a
where l_id in (
select b.bl_id
from a,b
where a.o_id = 17
and a.o_id = b.bo_id )
OR
(a.o_id = 17)
COUNT(*)
----------
2
----------
2
1 row selected.
The
table data is as listed below ....
SQL> select * from a;
O_ID L_ID
---------- ----------
17 NULL
NULL 42
---------- ----------
17 NULL
NULL 42
2 rows selected.
SQL> select * from b;
BO_ID BL_ID
---------- ----------
17 42
17 43
17 44
---------- ----------
17 42
17 43
17 44
3 rows selected.
Regards,
Karthik
Mohan
TCS Consultant at GEP
(HK)
DialComm 3310962
ISD : 852-26290962
-----Original Message-----
From: Niyi Olajide [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 25, 2001 4:36 PM
To: Multiple recipients of list ORACLE-L
Subject: RE: SQL PROBLEMCan you try this:select count (1) from (select 1 from table_ a where ord_id = 17unionselect 1 from table_b where ord_id = 17)/Hi,Favour me in suggest a hint in writing a sql for following scenaio:Table A has 2 columns ord_id and line_idexample rows are:ord_id line_id17 nullnull 42Table B has columns ord_id and line_idord_id line_id17 4217 4317 44I have to write a sql to count(*) from table A where ord_id=17 ..as u see from table B line 42 is row of ord_id=17 ..so i wantcount(*) should show =2 from tabel Abut if i do count(*) from table A where ord_id=17..it shows 1..i need to put another condition which will check line id withTABLE B and if it is for this particular order ...add that also incount(*).............I know scenario is little fuzzy sorry for it..but if u got my pointkindly respond.ThanksHarvinder
