Re: SQL Help?
Date: Fri, 17 Aug 2001 10:32:59 -0700
Message-ID: <3b7d55b1$0$325$8eec23a_at_newsreader.tycho.net>
Thx Steve,
I couldn't get decode to work at all.
This is how I solved the problem:
SQL> select cat.*, (select count(faq.cat_id) from mdfaq_faq_cat faq 2 where cat.id = faq.cat_id and faq.faq_id = 23) as selected from mdfaq_category cat;
ID NAME
---------- ----------------------------------------------------------------SELECTED
6 Solid Edge 0 7 MicroStation 1 10 MDSync 1
Thx for your help.
Barry
"Steve Long" <slong3_at_mediaone.net> wrote in message
news:Cq%e7.1606$L8.23537_at_typhoon.jacksonville.mediaone.net...
> use the DECODE function if there the column is guarantted to be not null,
or
> use a combination of DECODE and NULVAL if the column can be null. any
good
> SQL reference book will give you proper usage.
>
> "Barry Prentiss" <thebear_at_antispam.stanford.edu> wrote in message
> news:3b7c3bd8$0$322$8eec23a_at_newsreader.tycho.net...
> > Hi,
> > Here's another SQL query problem:
> >
> > How do I construct a query that returns 1 if a value is present and zero
if
> > it is not, for a list of values returned in another query?
> >
> > i.e. select a.id, a.name, c.selected from table-with-id-and-name a,
> > (select 1 as selected from another-table b if a.id = b.id
> > or select 0 as selected from another-table b if a.id != b.id ) c;
> >
> > Thx in Advance,
> > Barry Prentiss
> >
> >
>
>
Received on Fri Aug 17 2001 - 19:32:59 CEST