If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > query with multiple dates

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-17-07, 11:52
nmxnmx nmxnmx is offline
Registered User
 
Join Date: Mar 2007
Posts: 3
Question query with multiple dates

Hi, I'd like to know if someone can help me with the next query:

I have one table like this:

id_product | dsc_product |value_one | value_two | value_three | date |
-----------+-------------+----------+-----------+-------------+------+

So I want to make a query when the product on base to date, but not all the columns are going to be based on the same date, I mean, let's supose I have products with the field date from 01/01/01 to 03/31/07, but for the column "value_one" I need that the query get the results of products from the 01/01/01 to 03/31/07 but for the others one I just need that the date is from 03/01/07 to 31/03/07, I mean of the current month.

I hope you have understand to me and someone can help me.

Greetings
Reply With Quote
  #2 (permalink)  
Old 03-17-07, 12:05
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
could you repeat the question please?

perhaps you could show some rows of sample data

it almost sounded like your date column has multiple values in it
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 03-17-07, 13:07
nmxnmx nmxnmx is offline
Registered User
 
Join Date: Mar 2007
Posts: 3
thanks for reply, I will attach an image of a example table:

query with multiple dates-table_example.jpg

for example in that table I need a query where I need to get the value1 from 01/01/05 up to 31/03/07 but for the other values (value2, value3, etc) I need just the value from 01/03/07 up to 31/03/07
Reply With Quote
  #4 (permalink)  
Old 03-17-07, 13:13
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
value_one from 01/01/05 up to 31/03/07 is six different values

from 01/03/07 up to 31/03/07 is only three different values

could you show an example of the results that you want the query to produce
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 03-17-07, 13:28
nmxnmx nmxnmx is offline
Registered User
 
Join Date: Mar 2007
Posts: 3
Well specifically I need to obtain all the products that match with certain criteria and date, I cannot do something like:

Code:
SELECT * FROM table WHERE ... AND date BETWEEN #01/01/05# AND #31/03/07#
because I would obtain the value of all columns on that range, but I want the values from that range for the first column only, for the others I need to obtain just of the 01/03/07 to 31/03/07 range.
Reply With Quote
  #6 (permalink)  
Old 03-17-07, 15:39
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
could you show an example of the results that you want the query to produce
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On