Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2008
    Posts
    464

    Unanswered: From the beginning of the current month

    Hi guys

    Could someone please help me write the syntax to select data from a 9i database starting from the beginning of the current month for every day?

    E.g., on any particualr day of the month, the query selects data from the first of the month and displays the data day-wise.

    I tried:

    Code:
    SELECT
          AA,trunc(datetime,'DD') DATETIME,
    WHERE DATETIME > TRUNC(SYSDATE,'MM')-1/86400
      group by AA,trunc(datetime,'DD')
    But it doesn't appear to have worked.

    Regards
    Shajju

  2. #2
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    SELECT
    AA,trunc(datetime,'DD') DATETIME,
    from my_table
    WHERE DATETIME > TRUNC(SYSDATE,'month')-1/86400
    group by AA,trunc(datetime,'DD')
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  3. #3
    Join Date
    Aug 2009
    Location
    Olympia, WA
    Posts
    337
    No need to trim off that second. Just do:
    Code:
    SELECT AA, trunc(datetime) datetime
    FROM foo
    WHERE datetime >= trunc(SYSDATE, 'month')

  4. #4
    Join Date
    Aug 2008
    Posts
    464
    Appreciated....Thanks guys.

Posting Permissions

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