For an access database that looks like this: (All text fields)
Co1 Co2 Co3 Co4 A k t N1 B k t N2 A m t N3 B k z N4 A k z N5 C m t N6 C k z N7 C k t N8 A k t N9 C m t N10
I need to create some kind of reports that would do the following:
The results needs to select rows:
- Ordered by Co1 first
- then ordered by Co2
- only include data where Co3 = t or r
- when Co3 is NOT t nor r, then all other rows with a prior C04 where Co1 AND Co2 were the same as the current row are also excluded
1,2 and 3 are extremely easy to do (Order by and Where clause respectively) but can #4 be done in access SQL? If it can't, I'll make a small C# app that loops through the data but I feel this must be possible to do in SQL and if it can that would definately be much better.
The actual query and database is more complicated but #4 is where I get stuck.
With the example I gave the result would be:
A m t N3 A k t N9 C m t N6 C m t N10 C k t N8
I believe this cover all possible cases.
Precision, we use the fourth column (C4 in this example) to determine the order but it is a text field with characters and digits in it. The field is a letter followed by 2 digits: A01, A02,..A99, B01, etc... Precision #2, I'm not the one to blame for this database design. :P
So, to the SQL guru's among us, can this be done in access SQL? How?
Thank you very much for any help you can provide.