PC Review


Reply
 
 
JE
Guest
Posts: n/a
 
      16th Feb 2010
I want to add a column to an existing query that is a counter. Example of
data and desired result below. The criteria is: If Name, Symbol and Date are
different, counter changes; if Name, Symbol and Date are same, same counter
as line above.

I read about DCount but was unsuccessful. Any insight or direction to
reference material is most appreciated.

Name Account# Symbol Date
ANDREW 12345 AAA 08-Jan-09
ANDREW 12345 AAA 20-Jan-09
ANDREW 12345 BBB 20-Jan-09
ANDREW 12345 BBB 28-Jan-09
BOB 98765 CCC 30-Jan-09
BOB 98765 CCC 30-Jan-09
BOB 98765 CCC 30-Jan-09


Want
Counter Name Account# Symbol Date
1 ANDREW 12345 AAA 08-Jan-09
2 ANDREW 12345 AAA 20-Jan-09
2 ANDREW 12345 BBB 20-Jan-09
3 ANDREW 12345 BBB 28-Jan-09
4 BOB 98765 CCC 30-Jan-09
4 BOB 98765 CCC 30-Jan-09
4 BOB 98765 CCC 30-Jan-09

 
Reply With Quote
 
 
 
 
KARL DEWEY
Guest
Posts: n/a
 
      17th Feb 2010
Try these three queries --
JE_1 --
SELECT JE.Name, JE.[Account#], JE.Symbol, JE.Date, (SELECT Count(*) FROM JE
AS [XX] WHERE [XX].[Name] & [XX].[Account#] & [XX].[Symbol] & [XX].[Date] <=
[JE].[Name] & [JE].[Account#] & [JE].[Symbol] & [JE].[Date]) AS [Counter]
FROM JE
ORDER BY JE.Name, JE.[Account#], JE.Symbol, JE.Date;

JE_2 --
SELECT JE_1.Name, JE_1.[Account#], JE_1.Symbol, JE_1.Date, Count(*) AS ZZ
FROM JE_1
GROUP BY JE_1.Name, JE_1.[Account#], JE_1.Symbol, JE_1.Date
ORDER BY JE_1.Name, JE_1.[Account#], JE_1.Symbol, JE_1.Date;

SELECT JE_1.Name, JE_1.[Account#], JE_1.Symbol, JE_1.Date,
IIf([JE_1].[Counter]-[ZZ]=0,1,[Counter]-[ZZ]) AS Count_X
FROM JE_1 INNER JOIN JE_2 ON (JE_1.Date = JE_2.Date) AND (JE_1.Symbol =
JE_2.Symbol) AND (JE_1.[Account#] = JE_2.[Account#]) AND (JE_1.Name =
JE_2.Name);

--
Build a little, test a little.


"JE" wrote:

> I want to add a column to an existing query that is a counter. Example of
> data and desired result below. The criteria is: If Name, Symbol and Date are
> different, counter changes; if Name, Symbol and Date are same, same counter
> as line above.
>
> I read about DCount but was unsuccessful. Any insight or direction to
> reference material is most appreciated.
>
> Name Account# Symbol Date
> ANDREW 12345 AAA 08-Jan-09
> ANDREW 12345 AAA 20-Jan-09
> ANDREW 12345 BBB 20-Jan-09
> ANDREW 12345 BBB 28-Jan-09
> BOB 98765 CCC 30-Jan-09
> BOB 98765 CCC 30-Jan-09
> BOB 98765 CCC 30-Jan-09
>
>
> Want
> Counter Name Account# Symbol Date
> 1 ANDREW 12345 AAA 08-Jan-09
> 2 ANDREW 12345 AAA 20-Jan-09
> 2 ANDREW 12345 BBB 20-Jan-09
> 3 ANDREW 12345 BBB 28-Jan-09
> 4 BOB 98765 CCC 30-Jan-09
> 4 BOB 98765 CCC 30-Jan-09
> 4 BOB 98765 CCC 30-Jan-09
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Inbox Unread Blue Counter and Deleted Items Counter. Chris Baldassano Microsoft Outlook Discussion 1 20th Oct 2008 05:18 PM
Performance Counter Next Value always returns zero (MS Exchange counter) Bobby Microsoft Dot NET Framework 0 4th Jul 2007 04:33 PM
Use hit counter for page counter JL Microsoft Frontpage 1 26th Sep 2005 06:53 AM
access counter / hit counter not based on page reloads? Chuck Chopp Microsoft Frontpage 3 9th Feb 2005 10:30 AM
Epson C64 Protection Counter (Waste Ink Counter) Solution Santos L. Halper Printers 0 6th Jul 2004 02:28 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:41 PM.