RotoGuru Computer Forum

View the Forum Registry

XML Get RSS Feed for this thread


Self-edit this thread


0 Subject: SQL query help

Posted by: RecycledSpinalFluid
- Dude [204401122] Thu, Dec 31, 2009, 00:39

Access/SQL is not my strong point, so I'm asking for some help.

In an Access MDB, I have a table (tblHistory) that looks like this:

dDate (a date/time field)
iIdentNumber (integer)
iCount (integer)

Now, what I want to do is make a query that shows the iIdentNumber where the iCount has incremented over a 1 day period (from [date - 1] to [date].

Make sense? I swear I've done this before, but its escaping me now.

Any help is appreciated.
1Dr. Doom
      ID: 430271612
      Thu, Dec 31, 2009, 15:27
Assuming iIdentNumber is the key field.

One way might be

select iIdentNumber
from foo t1
join foo t2
where t1.iIdentNumber = t2.iIdentNumber
and t1.dDate = t2.dDate -1
and t1.iCount > t2.iCount
;

Not sure if the syntax is exactly right but the idea should be close.
2RecycledSpinalFluid
      Dude
      ID: 204401122
      Thu, Dec 31, 2009, 17:34
Ah! Many thanks. Wasn't thinking JOIN the table to itself. Built it with the Query Wizard in Access after looking at your suggestion and its good to go now (and rather bloated looking)!

Thanks again!
RotoGuru Computer Forum

View the Forum Registry

XML Get RSS Feed for this thread


Self-edit this thread




Post a reply to this message:

Name:
Email:
Message:
Click here to create and insert a link
Click here to insert a block of hidden (spoiler) text
Ignore line feeds? no (typical)   yes (for HTML table input)


Viewing statistics for this thread
Period# Views# Users
Last hour11
Last 24 hours11
Last 7 days65
Last 30 days1311
Since Mar 1, 200752941795