PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Deepak Shah <shahdeepakj at yahoo dot com>
Subject: RE: displaying limited number of rows
Date: Mar 29 2001 2:07AM

Michael / Joseph,
Hi!

You can resolve this with a SELF-JOIN.  

create table pubs
(name char(30) not null)

insert pubs
values ("Joseph Pantera")
insert pubs
values ("Michael Peppler")
insert pubs
values ("Deepak Shah")
insert pubs
values ("Larry Wall")

select count(*), A.name
from tempdb..pubs A, tempdb..pubs B
where A.name >= B.name
group by A.name

Deepak Shah

--- Michael Peppler  wrote:
> Pantera, Joseph F. writes:
>  > Follow-on question along these lines
> (probably easier, although I know how
>  > to do this in Oracle, but not Sybase)...  If
> I want to place a  column
>  > number next to the output from a query
> indicating where I am at in the
>  > output such as a list of names:
>  > 
>  > Column1:  Column2:
>  > 1         Name #1
>  > 2         Name #2
>  > 3         Name #3
>  > .           .
>  > .           .
>  > .           .
>  > N         Name #N
>  > 
>  > How do I do this in my query?
> 
> I think you can do this by playing with
> identity(), but you
> have to do a select into, like so:
> 
> select column1 = identity(5), column2 into #t
> from table where ...
> select * from #t
> 
> This can be run as a single command.
> 
> I don't think there is any way to dynamically
> number a result set with
> Sybase (no pseudo-rownum value).
> 
> Michael
> -- 
> Michael Peppler - Data Migrations Inc. -
> mpeppler@peppler.org
> http://www.mbay.net/~mpeppler -
> mpeppler@mbay.net
> International Sybase User Group -
> http://www.isug.com
> Sybase on Linux mailing list:
> ase-linux-list@isug.com
> 


__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/?.refer=text