Results 1 to 6 of 6
  1. #1
    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

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Mar 2007
    Posts
    3
    thanks for reply, I will attach an image of a example table:

    Click image for larger version. 

Name:	table_example.jpg 
Views:	32 
Size:	24.8 KB 
ID:	6895

    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

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    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.

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    could you show an example of the results that you want the query to produce
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •