SQL question

"Syed.Alam" <[email protected]> Thu, 16 May 2002 15:22:12 -0500
Newsgroups gmane.comp.windows.devel.oledb.devel
Message-ID <[email protected]>
Hi

Even though I am using OLEDB driver, but it is more a SQL syntax related
problem:

I am writing a query in which order clause is sort of dynamically built up
like:

select POG_NUM_N ,DEPT_I , ( select distinct SECT_I from t_pog_detail where
P.POG_NUM_N = POG_NUM_N ) as SECTOR
from
pog_scma p
order by DEPT_I ,
COALESCE (dept_i, SECTOR)

or

select POG_NUM_N ,DEPT_I , ( select distinct SECT_I from t_pog_detail where
P.POG_NUM_N = POG_NUM_N ) as SECTOR
from
pog_scma p
order by DEPT_I ,
case DEPT_I
 WHEN 52 THEN  ITEM_I
 ELSE  SECTOR
END

In both the cases, ISQL/W has probelm with column SECTOR with in CASE and
COALESCE statement. What can be done here?

Thanks

PS: I am using SQL 6.5