473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Logic help

Sam
I'm working on a small application and I am stuck on the logic behind
one of the queries I want to write. I've always considered myself to be
a good problem solver and it depresses me that I can't figure this out.

I don't really need any SQL syntax or anything, just help with ANDs,
ORs, NOTs, etc...

I have a table that has a column for a specific action. Each row in the
table represents when an action is taken on a particular item. The item
itself can show up numerous times in the table for different actions.

There are four actions that can be taken, and they are sequential. I
won't get into too much detail, so I will just call them A, B, C, and
D. Action A must be taken for a particular ID# before B can be taken.
The program logic itself handles that validation. So, the ID# that has
action C *will* have B and A.

The query I am trying to write is to just list the ID and the latest
action taken. So, ID#1 may have A, B, and C - but I only want to list
C. ID#2 may have A-D, so I'd only list D.

To make matters worse, action C can be taken numerous times. So for one
ID number, you can have multiple Cs (The "action log" uses an
autonumber PK). So in my query, where I'll have an item that is on
action C, I need the *latest* C.

So, in short, I am trying to find a way to get the latest action for a
particular item.

Would it be easiest to perform logic in the query to pull this
information, or should I timestamp each action and just pull the latest
action for each record? Any other suggestions?

Nov 13 '05 #1
2 1521
Rog
If your actions are actually called A, B, C and D, you can create a
"totals" query (click on the sum or totals button). On the total line
select "Group by" for the ID# and "Max" for the action, since B > A
etc.

If the actions have different names you can create a table containing a
record for each of your 4 actions, and give them numbers 1 to 4 (or a
letters A to D like in your example), e.g. ActionName = "Start of
process", ActionNumber = 1 for your first record, etc. In your query,
link your two tables on the action name and use the action number (or
letter) in the Max column.

Nov 13 '05 #2
Sam
Thanks, Rog. I think I'm going to take your advice about the table
giving each action a number. I'll try that and tweak things around...
and hopefully everything will work out.

Thanks

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: nc | last post by:
My iterator can find my collection when my Action class calls my jsp directly, however when my Action class calls an html file that is set up with IFrames (one of which is loading that same jsp), I...
0
by: radha | last post by:
Hai all, My problem not just releated to sql. My problem is releated to good logic. I should not this type of questions hear. But just i am trying. If any body gave suggestions, or help i am...
5
by: Shabam | last post by:
I'm having a calendar feature developed whereby users can add recurring events. These recurring events can have start and end dates, meaning they will recur only within a date range. For...
7
by: Stephen | last post by:
I have some code which I call from a custom validator however I seem to have got the logic wrong and im having trouble figuring out how to write my code to get things to work the way I require....
24
by: cassetti | last post by:
Here's the issue: I have roughly 20 MS excel spreadsheets, each row contains a record. These records were hand entered by people in call centers. The problem is, there can and are duplicate...
14
by: rabbitrun | last post by:
Hi Everyone, I work for a financial company. I am planning to give a presentation to rest of the development team (15 people) here on moving server side logic to client-side javascript for an...
1
by: jonathan184 | last post by:
how to monitor and find out if files test1_* and test2_* files were sent in an hour and if not send an email This is on a unix system basically I got a cronjob that runs every sec polling a ftp dir...
9
by: SAL | last post by:
Hello, I have a Dataset that I have table adapters in I designed using the designer (DataLayer). I have a business logic layer that immulates the DataLayer which may/may not have additional logic...
15
by: bruno.desthuilliers | last post by:
On 27 juin, 18:09, "John Salerno" <johnj...@NOSPAMgmail.comwrote: For which definitions of "content" and "logic" ??? The point of mvc is to keep domain logic separated from presentation logic,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.