Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Can it be done in a single statement?

2 posts in JConnect version 3.0 Last posting was on 1998-11-13 01:06:07.0Z
Chuck May Posted on 1998-11-12 22:21:56.0Z
From: "Chuck May" <may@ims.nci.nih.gov>
Subject: Can it be done in a single statement?
Date: Thu, 12 Nov 1998 17:21:56 -0500
Lines: 17
X-Newsreader: Microsoft Outlook Express 4.72.3110.5
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Message-ID: <YMOIcFoD#GA.217@forums.powersoft.com>
Newsgroups: sybase.public.jconnect30,sybase.public.jconnect40
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jconnect30:359 sybase.public.jconnect40:216
Article PK: 255727

I am trying to do a fairly simple search, but I can't figure out how to do
it in a single statement. I have a table that has two columns: id and
status. I need to produce a count of a specified id and a count of a
specified id where the status = 1.

Here are the two statements:

select count(*) from table where id = @id

select count(*) from table where id = @id and status = 1

Does anyone know of a way to create this stored procedure where I get a
single result set with two columns? Thanks,

Chuck


David Wolf Posted on 1998-11-13 01:06:07.0Z
Message-ID: <364B85FF.3CF143EF@sybase.com>
Date: Thu, 12 Nov 1998 20:06:07 -0500
From: David Wolf <dwolf@sybase.com>
Organization: Sybase, Inc.
X-Mailer: Mozilla 4.5 [en] (WinNT; U)
X-Accept-Language: en
MIME-Version: 1.0
To: Chuck May <may@ims.nci.nih.gov>
Subject: Re: Can it be done in a single statement?
References: <YMOIcFoD#GA.217@forums.powersoft.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.jconnect30,sybase.public.jconnect40
Lines: 19
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jconnect30:358 sybase.public.jconnect40:215
Article PK: 254621

select (select count(*) from table where id = @id), (select count(*) from
table where id = @id and status = 1)

Dave Wolf
Jaguar Product Team

Chuck May wrote:

> I am trying to do a fairly simple search, but I can't figure out how to do
> it in a single statement. I have a table that has two columns: id and
> status. I need to produce a count of a specified id and a count of a
> specified id where the status = 1.
>
> Here are the two statements:
>
> select count(*) from table where id = @id
>
> select count(*) from table where id = @id and status = 1
>
> Does anyone know of a way to create this stored procedure where I get a
> single result set with two columns? Thanks,
>
> Chuck