Results 1 to 4 of 4

Thread: Today Function

  1. #1
    Join Date
    Dec 2005
    Posts
    11

    Unanswered: Today Function

    Hi All,

    I am using today function to get today -7 and today -1.
    My query works But I am getting a different rowcount (the rowcount is pretty huge) when I select it from systables and when I don't. Do I have to include systables in the query or not. Will my logic work if I don't include the systables in the query, or do I have to include it.


    select a.txn_dt
    from sales a, systables b
    where a.yearmonth >=200601
    and a.txn_dt between today -7 and today -1

    This has 15964326 rowcount


    select txn_dt
    from sales
    where yearmonth >=200601
    and txn_dt between today -7 and today -1

    This has 126701 rowcount


    Thank you all for your help.

  2. #2
    Join Date
    Nov 2004
    Posts
    143
    Hello,

    In your first query you have not given any join condition betwn sales and systables, so should expect the AxB resultset.

    Bye

    Nitin

  3. #3
    Join Date
    Dec 2005
    Posts
    11
    Hi Nitin,

    I didn't clearly understand. Should I need to put the join condition or not. could you specify more on it. Thank you so much.

    I want txn_dt which is between sysdate-7 and sysdate -1, everytime I run it on Sunday, so that it will grab data for one week, and so that I don't have to keep on putting new dates every week I run the query.

    Thank you again.

  4. #4
    Join Date
    Nov 2004
    Posts
    143
    Hello,

    You dont need to systables into the query. There is no need for that. What you want is achievable from the 2nd query.
    The logic of 1st query is not correct, so it is given wrong count,thats what I meant.

    Bye

    Nitin

Posting Permissions

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