Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2010
    Posts
    1

    Unanswered: SQL question If SELECT

    Hi I am new to SQL so please be patient. I have a little SQL which runs everyday which displays the previous days receipts, using sysdate - 1. However when run on Mondays the -1 needs to be -3. I would like to use the day of week function but don't know how to build that into the SQL. See current code below. Any help appreciated.

    SELECT
    fld1, fld2, fld3, fld4
    FROM my_table
    WHERE trunc(date_returned) >= trunc(sysdate) - 1 (I would like the -1 to be a -3 on a Monday so that it pulls data to Friday)

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    Read The Fine Manual on DECODE() function
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

Posting Permissions

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