473,387 Members | 1,844 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,387 software developers and data experts.

Find least date greater than another date

78
I have one table of transactions, another table of price quotes. Transactions are nearly daily; quotes are periodic, roughly once per week. In a query, I want to pull the oldest (or least date) price quote whose date is greater or equal to the transaction date (trying to find the nearest price quote to compare to actual price paid). I have criteria for the price quote date as >=Trans Date, and tried setting the field to min or last, but these don't do anything. Can someone fill in the missing piece? Thanks.
Apr 2 '08 #1
15 3545
kpfunf
78
Bump .
Apr 3 '08 #2
NeoPa
32,556 Expert Mod 16PB
Can you provide table metadata for us to work with (both tables please).

Here is an example of how to post table MetaData. Please use this format in your post :
Expand|Select|Wrap|Line Numbers
  1. Table Name=[tblStudent]
  2. Field; Type; IndexInfo
  3. StudentID; AutoNumber; PK
  4. Family; String; FK
  5. Name; String
  6. University; String; FK
  7. Mark; Numeric
  8. LastAttendance; Date/Time
Apr 3 '08 #3
kpfunf
78
Expand|Select|Wrap|Line Numbers
  1. Table Name = [Zenith]
  2. Field; Type; IndexInfo
  3. Invoice Number; Number
  4. Transaction Date; Date/Time
  5. Tail Number; Text
  6. Quantity; Text
  7. Charge; Text
Expand|Select|Wrap|Line Numbers
  1. Table Name = [Fuel]
  2. Field; Type; IndexInfo
  3. FuelID; Autonumber; PK
  4. FuelType; Number
  5. Price; Currency
  6. VendorID; Number
  7. Date; Date/Time
Apr 4 '08 #4
NeoPa
32,556 Expert Mod 16PB
Nicely done :)

I think I'm going to need to play with this a little first though, to determine the best way of linking the tables together.

Give me a while to look at it at home over the weekend, but feel free to bump any time 24 hours have passed with no activity.
Apr 4 '08 #5
FishVal
2,653 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. Table Name = [Zenith]
  2. Field; Type; IndexInfo
  3. Invoice Number; Number
  4. Transaction Date; Date/Time
  5. Tail Number; Text
  6. Quantity; Text
  7. Charge; Text
Expand|Select|Wrap|Line Numbers
  1. Table Name = [Fuel]
  2. Field; Type; IndexInfo
  3. FuelID; Autonumber; PK
  4. FuelType; Number
  5. Price; Currency
  6. VendorID; Number
  7. Date; Date/Time
Hi, kpfunf.

Relations between the tables are, to say the least, not obvious. Would you clarify how a record in [Zenith] table could be related to a correspondent record in [Fuel] table?

Regards,
Fish.
Apr 4 '08 #6
kpfunf
78
My fault for not clarifying that. Zenith is a specific vendor, so it would be matched on Vendor ID (criteria). The reason I left out most detail was I think somewhere I've seen a solution to this type of problem before (or similar), and thought it easy (and seperate from the actual data, etc.), just some sort of criteria on the date selection.
Apr 4 '08 #7
NeoPa
32,556 Expert Mod 16PB
My fault for not clarifying that. Zenith is a specific vendor, so it would be matched on Vendor ID (criteria). The reason I left out most detail was I think somewhere I've seen a solution to this type of problem before (or similar), and thought it easy (and seperate from the actual data, etc.), just some sort of criteria on the date selection.
That is SO wrong.

While the solution may be as simple as that, without clear information to work from, finding that solution will be difficult with incorrect information.

It's really best to answer the questions with the actual answers if we're not to find problems in the process.
Apr 4 '08 #8
FishVal
2,653 Expert 2GB
Zenith is a specific vendor, so it would be matched on Vendor ID .........
You definitely need to read Database Normalization and Table structures article. There is no sense to build queries, until you redesign your table structure to look more like normalized one.

Kind regards,
Fish
Apr 5 '08 #9
kpfunf
78
NeoPa,
You are completely correct. I will try to be specific with my future posts.

FishVal,
The Zenith table is just one of many tables that are data downloaded/ submitted by the vendor and cannot simply be changed. I understand the table structure is not perfect but that's what I have to work with (you should see some of the other tables :). Unfortunately, because each vendor has various formatting and verbage, I have to have seperate tables and queries. This surely isn't "optimal", but it does work for what we need.
Apr 7 '08 #10
FishVal
2,653 Expert 2GB
The Zenith table is just one of many tables that are data downloaded/ submitted by the vendor and cannot simply be changed. I understand the table structure is not perfect but that's what I have to work with (you should see some of the other tables :). Unfortunately, because each vendor has various formatting and verbage, I have to have seperate tables and queries. This surely isn't "optimal", but it does work for what we need.
Ok. I will not argue further. ;) Its your own choice to sacrifice database design for the sake of "easy import". Take a look at Sub Query Problem. The solution I've provided there is not the most beautiful one but seems to work.

Regards,
Fish
Apr 7 '08 #11
NeoPa
32,556 Expert Mod 16PB
OK.

Assuming the tables as laid out in your post #4 then, how are the two tables linked?
Apr 7 '08 #12
kpfunf
78
The fields would be linked by limiting the Vendor Id to a specific value. I used FishVal's example and have a decent workaround that will do for now as we rethink some of this. I'm learning as I go that there are so many exceptions, a general rule is getting hard to use. Thanks NeoPa and FishVal for all your help!
Apr 8 '08 #13
NeoPa
32,556 Expert Mod 16PB
I sort of get where you're coming from, but I still see no way of linking the two tables, even if [Fuel] is limited by [VendorID] (There's no similar field in your other table - [Zenith]).

This may not matter for now as you have a work around, but if/when you decide you'd like to proceed we will need to know :)
Apr 8 '08 #14
kpfunf
78
Thanks again NeoPa. FYI Zenith has a unique Vendor ID, so I'd limit it that way. Again, my lack of clarity on here.
Apr 8 '08 #15
FishVal
2,653 Expert 2GB
Hi, kpfunf.

Though I've promised not to argue on the tables structure I would stay it once more. [Price Quote] -> [Sales] is so classic example of one-to-many relationship ... , you just have a very improper tables design. ;)
I would strongly encourage you to look for a more intelligent import routine to store incoming quotes in normalized tables. Really, tables designed to satisfy incoming data format is like swallowing candies in wrappers.

Best regards,
Fish.

P.S. If you want to reconsider you db design, then start a new thread and post hyperlink to it here.
Apr 8 '08 #16

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

Similar topics

9
by: Hebar Tiltwobler | last post by:
I need to figure out if the current date (passed in as a string) is equal to or greater then a field in my database in the format of- M/D/YYYY AND if the date is less then another field in my...
2
by: James Foreman | last post by:
I'm building a revenue management tool and this requires some understanding of how good my forecast accuracy is. Therefore I'm trying to collect the mean absolute percentage error (MAPE) on a...
13
by: Sue | last post by:
I'm working on a database that keeps track of employees hired by a general contractor on a project by project basis. These employees are hired to work on a project and are then laid off either at...
3
by: Massimiliano Alberti | last post by:
Can someone check this? If it's OK, you can use however you want... :-) It should search for an element in an array and, if it can't find it, return the next element. key is what you are...
5
by: jty202 | last post by:
I have string that contains a date in this format (14-Jan-05). I want to store in date object if theres one and access each part of the date (month, year, dates, day of week). Specifically I...
67
by: PC Datasheet | last post by:
Transaction data is given with date ranges: Beginning End 4/1/06 4/4/06 4/7/06 4/11/06 4/14/06 4/17/06 4/18/06 4/21/06 426/06 ...
1
by: Freddie | last post by:
Hello everyone: i am trying to compare a MAX(DATE) from one table that would be greater than a date in another. first_table compname MYDATE abc comp 2006-09-26 09:19:43.250
2
by: bml337 via AccessMonster.com | last post by:
I need to create a supervisory log for my clients. The log table has the following fields date, checkbox and notes. now for the tricky part... one log is weekly and should be generated every...
3
by: Harlequin | last post by:
I must start this posing by making the point that I am NOT a VB programmer and I'm something of a Newbie to MS Access. I can program in a number of languages (Java, Javascript, PERL,PHP and TCL) but...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.