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.

Help with an SQL Statement.

6 posts in General Discussion Last posting was on 2004-11-10 10:26:24.0Z
Jamin Dunivan Posted on 2004-11-09 15:49:35.0Z
Sender: 977.4190e520.1804289383@sybase.com
From: Jamin Dunivan
Newsgroups: ianywhere.public.general
Subject: Help with an SQL Statement.
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4190e70f.9bb.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 9 Nov 2004 07:49:35 -0800
X-Trace: forums-1-dub 1100015375 10.22.241.41 (9 Nov 2004 07:49:35 -0800)
X-Original-Trace: 9 Nov 2004 07:49:35 -0800, 10.22.241.41
Lines: 19
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:3834
Article PK: 7732

I apologize if this is in the wrong area to ask this
question. I havent done a lot of work with SQL so forgive
me if this is easy. I need to find specific records in 1
table. Below is an example.

Asset# Sort#
B1000 1
B1000 2
B1000 3
B1001 1
B1001 2

I need to extract(SELECT) the records with the largest
number in the Sort# field. In the above example" B1000 3"
and "B1001 2" are the fields I am looking for. Any ideas?
I cant quite wrap my brain around it.

Thanks
Jamin


anil k goel Posted on 2004-11-09 17:32:48.0Z
From: "anil k goel" <firstname.no-junk.lastname@spam.ianywhere.com>
Newsgroups: ianywhere.public.general
References: <4190e70f.9bb.1681692777@sybase.com>
Subject: Re: Help with an SQL Statement.
Lines: 39
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: anilgoel-pc.sybase.com
X-Original-NNTP-Posting-Host: anilgoel-pc.sybase.com
Message-ID: <4190ff40$1@forums-1-dub>
Date: 9 Nov 2004 09:32:48 -0800
X-Trace: forums-1-dub 1100021568 10.25.107.153 (9 Nov 2004 09:32:48 -0800)
X-Original-Trace: 9 Nov 2004 09:32:48 -0800, anilgoel-pc.sybase.com
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:3840
Article PK: 7736

Is this what you are looking for:

Select Asset#, Max( Sort# ) from Table group by Asset#

This query returns, for each distinct Asset#, a row containing the largest
number in the Sort# field for that Asset#.

--
-anil
Research and Development, Query Processing
iAnywhere Solutions Engineering

-------------------------------------------------------------------------
** Whitepapers, TechDocs, bug fixes are all available through the **
** iAnywhere Developer Community at http://www.ianywhere.com/developer **
-------------------------------------------------------------------------

<Jamin Dunivan> wrote in message news:4190e70f.9bb.1681692777@sybase.com...
>I apologize if this is in the wrong area to ask this
> question. I havent done a lot of work with SQL so forgive
> me if this is easy. I need to find specific records in 1
> table. Below is an example.
>
> Asset# Sort#
> B1000 1
> B1000 2
> B1000 3
> B1001 1
> B1001 2
>
> I need to extract(SELECT) the records with the largest
> number in the Sort# field. In the above example" B1000 3"
> and "B1001 2" are the fields I am looking for. Any ideas?
> I cant quite wrap my brain around it.
>
> Thanks
> Jamin


Jamin Dunivan Posted on 2004-11-09 18:05:43.0Z
Sender: d32.41910319.1804289383@sybase.com
From: Jamin Dunivan
Newsgroups: ianywhere.public.general
Subject: Re: Help with an SQL Statement.
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <419106f7.d9a.1681692777@sybase.com>
References: <4190ff40$1@forums-1-dub>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 9 Nov 2004 10:05:43 -0800
X-Trace: forums-1-dub 1100023543 10.22.241.41 (9 Nov 2004 10:05:43 -0800)
X-Original-Trace: 9 Nov 2004 10:05:43 -0800, 10.22.241.41
Lines: 48
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:3842
Article PK: 7739

I posted to the sybase.public.sqlanywhere.general like Reg
had said. I messed up on my example There should have been 2
or more records with entries "b1000 3". I was able to
get your results but it wasnt what I was looking for. THANK
YOU SO MUCH for trying!

> Is this what you are looking for:
>
> Select Asset#, Max( Sort# ) from Table group by Asset#
>
> This query returns, for each distinct Asset#, a row
> containing the largest number in the Sort# field for that
> Asset#.
>
> --
> -anil
> Research and Development, Query Processing
> iAnywhere Solutions Engineering
>
> ----------------------------------------------------------
> --------------- ** Whitepapers, TechDocs, bug fixes are
> all available through the ** ** iAnywhere Developer
> Community at http://www.ianywhere.com/developer **
> ----------------------------------------------------------
> ---------------
>
> <Jamin Dunivan> wrote in message
> news:4190e70f.9bb.1681692777@sybase.com... >I apologize if
> > this is in the wrong area to ask this question. I
> > havent done a lot of work with SQL so forgive me if this
> > is easy. I need to find specific records in 1 table.
> Below is an example. >
> > Asset# Sort#
> > B1000 1
> > B1000 2
> > B1000 3
> > B1001 1
> > B1001 2
> >
> > I need to extract(SELECT) the records with the largest
> > number in the Sort# field. In the above example" B1000
> > 3" and "B1001 2" are the fields I am looking for. Any
> > ideas? I cant quite wrap my brain around it.
> >
> > Thanks
> > Jamin
>
>


Reg Domaratzki (iAnywhere Solutions) Posted on 2004-11-09 17:15:34.0Z
From: "Reg Domaratzki \(iAnywhere Solutions\)" <Spam_bad_rdomarat@ianywhere.com>
Newsgroups: ianywhere.public.general
References: <4190e70f.9bb.1681692777@sybase.com>
Subject: Re: Help with an SQL Statement.
Lines: 41
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: rdomarat-pc.sybase.com
X-Original-NNTP-Posting-Host: rdomarat-pc.sybase.com
Message-ID: <4190fb36$1@forums-1-dub>
Date: 9 Nov 2004 09:15:34 -0800
X-Trace: forums-1-dub 1100020534 10.25.99.235 (9 Nov 2004 09:15:34 -0800)
X-Original-Trace: 9 Nov 2004 09:15:34 -0800, rdomarat-pc.sybase.com
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:3839
Article PK: 7737

The sybase.public.sqlanywhere.general would have been the best place for
this question. If you post there, Paul Horan will likely answer within a
day unless he's out of the office. Paul is a SQL Guru.

Translation : I can't wrap my head around it either. I could write a stored
procedure to do it, but there must be a way to do it using a single SQL
statement....

--
Reg Domaratzki, Sybase iAnywhere Solutions
Sybase Certified Professional - Sybase ASA Developer Version 8
Please reply only to the newsgroup

iAnywhere Developer Community : http://www.ianywhere.com/developer
iAnywhere Documentation : http://www.ianywhere.com/developer/product_manuals
ASA Patches and EBFs : http://downloads.sybase.com/swx/sdmain.stm
-> Choose SQL Anywhere Studio
-> Set "Platform Preview" and "Time Frame" to ALL

<Jamin Dunivan> wrote in message news:4190e70f.9bb.1681692777@sybase.com...
> I apologize if this is in the wrong area to ask this
> question. I havent done a lot of work with SQL so forgive
> me if this is easy. I need to find specific records in 1
> table. Below is an example.
>
> Asset# Sort#
> B1000 1
> B1000 2
> B1000 3
> B1001 1
> B1001 2
>
> I need to extract(SELECT) the records with the largest
> number in the Sort# field. In the above example" B1000 3"
> and "B1001 2" are the fields I am looking for. Any ideas?
> I cant quite wrap my brain around it.
>
> Thanks
> Jamin


Jamin Dunivan Posted on 2004-11-09 18:03:08.0Z
Sender: d32.41910319.1804289383@sybase.com
From: Jamin Dunivan
Newsgroups: ianywhere.public.general
Subject: Re: Help with an SQL Statement.
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4191065b.d8f.1681692777@sybase.com>
References: <4190fb36$1@forums-1-dub>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 9 Nov 2004 10:03:08 -0800
X-Trace: forums-1-dub 1100023388 10.22.241.41 (9 Nov 2004 10:03:08 -0800)
X-Original-Trace: 9 Nov 2004 10:03:08 -0800, 10.22.241.41
Lines: 48
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:3841
Article PK: 7738

Thanks I will post there.

> The sybase.public.sqlanywhere.general would have been the
> best place for this question. If you post there, Paul
> Horan will likely answer within a day unless he's out of
> the office. Paul is a SQL Guru.
>
> Translation : I can't wrap my head around it either. I
> could write a stored procedure to do it, but there must be
> a way to do it using a single SQL statement....
>
> --
> Reg Domaratzki, Sybase iAnywhere Solutions
> Sybase Certified Professional - Sybase ASA Developer
> Version 8 Please reply only to the newsgroup
>
> iAnywhere Developer Community :
> http://www.ianywhere.com/developer iAnywhere Documentation
> : http://www.ianywhere.com/developer/product_manuals ASA
> Patches and EBFs :
> http://downloads.sybase.com/swx/sdmain.stm
> -> Choose SQL Anywhere Studio
> -> Set "Platform Preview" and "Time Frame" to ALL
>
> <Jamin Dunivan> wrote in message
> > news:4190e70f.9bb.1681692777@sybase.com... I apologize
> > if this is in the wrong area to ask this question. I
> > havent done a lot of work with SQL so forgive me if this
> > is easy. I need to find specific records in 1 table.
> Below is an example. >
> > Asset# Sort#
> > B1000 1
> > B1000 2
> > B1000 3
> > B1001 1
> > B1001 2
> >
> > I need to extract(SELECT) the records with the largest
> > number in the Sort# field. In the above example" B1000
> > 3" and "B1001 2" are the fields I am looking for. Any
> > ideas? I cant quite wrap my brain around it.
> >
> > Thanks
> > Jamin
>
>


Breck Carter [TeamSybase] Posted on 2004-11-10 10:26:24.0Z
From: "Breck Carter [TeamSybase]" <NOSPAM__bcarter@risingroad.com>
Newsgroups: ianywhere.public.general
Subject: Re: Help with an SQL Statement.
Organization: RisingRoad Professional Services
Reply-To: NOSPAM__bcarter@risingroad.com
Message-ID: <55r3p0pk78dhrsmpgfjkk1l0idp550hqq6@4ax.com>
References: <4190e70f.9bb.1681692777@sybase.com> <4190fb36$1@forums-1-dub>
X-Newsreader: Forte Agent 2.0/32.640
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Original-NNTP-Posting-Host: ip67-93-228-42.z228-93-67.customer.algx.net
X-Original-Trace: 10 Nov 2004 02:26:18 -0800, ip67-93-228-42.z228-93-67.customer.algx.net
Lines: 17
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 10 Nov 2004 02:26:21 -0800, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 10 Nov 2004 02:26:24 -0800
X-Trace: forums-1-dub 1100082384 10.22.108.75 (10 Nov 2004 02:26:24 -0800)
X-Original-Trace: 10 Nov 2004 02:26:24 -0800, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:3850
Article PK: 7746

On 9 Nov 2004 09:15:34 -0800, "Reg Domaratzki \(iAnywhere Solutions\)"

<Spam_bad_rdomarat@ianywhere.com> wrote:

>The sybase.public.sqlanywhere.general would have been the best place for
>this question. If you post there, Paul Horan will likely answer within a
>day unless he's out of the office. Paul is a SQL Guru.

Paul is on vacation... "Dos cervezas por favor!"

Breck

--
SQL Anywhere Studio 9 Developer's Guide
Buy the book: http://www.amazon.com/exec/obidos/ASIN/1556225067/risingroad-20
bcarter@risingroad.com
RisingRoad SQL Anywhere and MobiLink Professional Services
www.risingroad.com