473,407 Members | 2,315 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,407 software developers and data experts.

An Odd Relationship

blyxx86
256 100+
I'm designing a new database.

I was writing it all down when I realized I needed to have a very unique (or not so unique) task done with a query, or report.

I am going to have a table called, "tblStatus"

It will contain values like, "Active, Completed, On Hold, Waiting For Parts"

The primary concern here is I will need to be able to display in a report (or query) the difference of dates between a unit that has a status of "On Hold" or "Waiting For Parts" and when it is marked "Completed" within the database.

The units are tracked by a serial number.

For example:
Date Serial Number Status
11/24 00051 On Hold
11/25 00753 Completed
… … …
12/2 00051 Completed

I would need a query, or report to display that on 11/24 the unit with serial 00051 went to status "On Hold" and then on 12/2 the unit with serial 00051 went to status "Completed" and possibly the difference between the two. (However, I know I can find how to find distance between two dates on the forums here so I do not need to fill up the forums with more of that explanation.)

Would it be something like... SELECT * FROM tblMain WHERE ((tblMain.status = "On Hold") AND (tblMain.Status = "Completed")) but only where Serial Number for the one "On Hold" = the Serial Number of the one "Completed"

how would I include a piece that says, ONLY IF Serial Number = Serial Number
Dec 12 '06 #1
1 1067
NeoPa
32,556 Expert Mod 16PB
The SQL could look something like :
Expand|Select|Wrap|Line Numbers
  1. SELECT [Serial Number],
  2.        Max(IIf([Status]='Active',[Date],Null)) AS ActiveDate
  3.        Max(IIf([Status]='Waiting For Parts',[Date],Null)) AS WaitingDate
  4.        Max(IIf([Status]='On Hold',[Date],Null)) AS HoldDate
  5.        Max(IIf([Status]='Completed',[Date],Null)) AS DoneDate
  6. FROM tblMain
  7. WHERE [Serial Number]=[Enter Serial Number]
  8. GROUP BY [Serial Number]
You may not need to select by Serial Number as they're already grouped together.
Dec 12 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Alcyone Oliveira | last post by:
------=_NextPart_000_000D_01C36572.F6480CE0 Content-Type: multipart/alternative; boundary="----=_NextPart_001_000E_01C36572.F6480CE0" ------=_NextPart_001_000E_01C36572.F6480CE0 Content-Type:...
0
by: Mike Sutton | last post by:
Please let me know what you think of this scheme I have come up with (not to imply that noone else has before me) for managing relationships. I have created an entities table with Individual and...
8
by: Andante.in.Blue | last post by:
Hello, I have just inherited a legacy Access 97 database. While going through it, I noticed something strange... its Relationships window (the one accessed by Tools --> Relationships) is almost...
2
by: Larry R Harrison Jr | last post by:
I have an Access 97 database with 2 tables that have a one-many relationship. I have a SQL statement in the "one" table which I want to execute and insert 7 records into the "many" table, and I...
7
by: francophone77 | last post by:
I deleted a relationship in the relationship view, but when I create a query that includes those two tables, the relationship reappears. When I go back to the relationship view there is NO...
0
by: Joey Lee | last post by:
Hi, I have created a dataset schema(*.xsd) which contain two element "InvoiceHeader" and "InvoiceDetail". I set the primary key of both the element. for example "InvoiceHeader" -> id and...
5
by: BrianDP | last post by:
This is a strange one-- I have an Access 2K database with a split front end/back end. There are two tables in the back end - RFile and RLine. There is a one to many relationship from...
1
by: BuckBaxter | last post by:
Recently had trouble creating a one-to-many relationship between Customer table and Order table. After drag & dropping the field CustomerNo (key) in Customer table to CustomerNo (foreign) in Order...
4
by: Phil Stanton | last post by:
Having spent ages sorting out the layout of my relationship window with about 60 tables and getting it all tidy and with enough of the tables visible to show the PK an FK relaionshipsOn a subseqent...
6
by: NicoleCartrette | last post by:
Going back to school is easier said than done.. This was posted to an older thread earlier but I don't think it got any attention. Your help is appreciated Professor requires we create a...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.