× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Yep, dense_rank is eaiser than my idea of ROW_NUMBER()

select fld1, dte1,
DENSE_RANK() OVER(ORDER BY dte1) as Date_Nbr,
dte2
from ctsc_w.pete;

note RANK() gives
BB8179 04/17/11 1 04/02/11
BE7214 04/17/11 1 04/02/11
BD9607 04/17/11 1 04/02/11
BB6382 04/17/11 1 04/02/11
BB7942 04/17/11 1 04/02/11
BE7487 04/17/11 1 04/02/11
BE7488 04/18/11 7 04/02/11
BE2178 04/18/11 7 04/02/11
BE1618 04/18/11 7 04/02/11
BE7489 04/18/11 7 04/02/11
BE2179 04/18/11 7 04/02/11
BD9608 04/21/11 12 04/02/11
BE2180 04/21/11 12 04/02/11
BE8955 04/21/11 12 04/02/11
BE1696 04/21/11 12 04/02/11

Charles

On Mon, Mar 7, 2011 at 4:27 PM, Schutte, Michael D
<Michael_Schutte@xxxxxxxxxxxx> wrote:
Actually you are going to want  dense_rank


Select column1, column2,
dense_rank() over(partition by column3 order by
column2), column3 from qtemp/test

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Pete Helgren
Sent: Monday, March 07, 2011 3:41 PM
To: Midrange Systems Technical Discussion
Subject: Counting Occurrences with SQL

I am have a data set that looks like the following:

BB8179      04/17/11     04/02/11
BE7214      04/17/11     04/02/11
BD9607      04/17/11     04/02/11
BB6382      04/17/11     04/02/11
BB7942      04/17/11     04/02/11
BE7487      04/17/11     04/02/11
BE7488      04/18/11     04/02/11
BE2178      04/18/11     04/02/11
BE1618      04/18/11     04/02/11
BE7489      04/18/11     04/02/11
BE2179      04/18/11     04/02/11
BD9608      04/21/11     04/02/11
BE2180      04/21/11     04/02/11
BE8955      04/21/11     04/02/11
BE1696      04/21/11     04/02/11

What I would like to do is count the unique occurrences of the first
date column.  Something like:

BB8179      04/17/11   1  04/02/11
BE7214      04/17/11   1  04/02/11
BD9607      04/17/11   1  04/02/11
BB6382      04/17/11   1  04/02/11
BB7942      04/17/11   1  04/02/11
BE7487      04/17/11   1  04/02/11
BE7488      04/18/11   2  04/02/11
BE2178      04/18/11   2  04/02/11
BE1618      04/18/11   2  04/02/11
BE7489      04/18/11   2  04/02/11
BE2179      04/18/11   2  04/02/11
BD9608      04/21/11   3 04/02/11
BE2180      04/21/11   3  04/02/11
BE8955      04/21/11   3  04/02/11
BE1696      04/21/11   3  04/02/11

Actually there are more columns involved here but this data set
illustrates the challenge.  Can't seem to wrap my head around the whole
thing but I may need a subselect to get the count of the occurrences...

Thanks

--
Pete Helgren
Value Added Software, Inc
www.asaap.com
www.opensource4i.com

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.

________________________________

Notice from Bob Evans Farms, Inc: This e-mail message, including any attachments, may contain confidential information that is intended only for the person or entity to which it is addressed. Any unauthorized review, use, disclosure or distribution is strictly prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message and any attachments.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.