Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2011
    Posts
    3

    Unanswered: Oracle date selection question

    So i am interning with the fleet division of the current city I live in and I am new to Oracle. I need to create quire where the last time a car was filled with gas is displayed so I came up with this and it works....

    select unit_dept_comp_main.unit_id, max(f_isstrans_v.issue_dt)
    from unit_dept_comp_main
    left join f_isstrans_v
    on unit_dept_comp_main.unit_id=f_isstrans_v.unit_id
    group by unit_dept_comp_main.unit_id

    Now I need to only show anything that hasn’t been filled last 45 days or more or hasn’t been filled at all (null) from today (current date whenever quire is ran)

    I have a feeling most of what I need is in the where clause. If anyone could help it would be greatly appreciated!!

  2. #2
    Join Date
    Apr 2008
    Location
    Iasi, Romania
    Posts
    561
    Provided Answers: 2
    SELECT *
    FROM
    (
    select unit_dept_comp_main.unit_id, max(f_isstrans_v.issue_dt) as max_data
    from unit_dept_comp_main
    left join f_isstrans_v
    on unit_dept_comp_main.unit_id=f_isstrans_v.unit_id
    group by unit_dept_comp_main.unit_id
    ) a
    WHERE a.max_data < current_date - 45
    Florin Aparaschivei
    DB2 9.7, 10.5 on Windows
    Iasi, Romania

  3. #3
    Join Date
    Apr 2011
    Posts
    3
    Thank You !! I havent tried it yet as its Saturday but it definitely looks along the line of what I needed. Much appreciated !! + rep

Posting Permissions

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