Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2012

    Unanswered: Montly Comparison

    I currently have been running two queries, pasting the results into excel, and combining the data to one dataset, but there must be an easier way. I need to show a comparison of Feb 2016 to Feb 2015. My query to get the data for one month would be
    Select flname, flsaleamt ,flsalesdate from flsales where flsaledate between '01/01/2016' and '01/31/20106'
    Then to capture the data for 2015 same query but change the year. Which gives me a data output of:
    Bl 2610 01/01/2016
    BI 1412 01/04/2016
    LL 200 01/10/2016
    EE 3200 01/14/2016
    EE 3200 01/21/206

    My ideal data output is:
    BI 4022 Jan-16
    BI 2300 Jan-15
    LL 200 Jan-16
    LL 400 Jan-15
    EE 6400 Jan-16
    EE 7000 Jan-15

    How would I need to ammend my query so that the data can be output like I need (or at least pretty close to that)

  2. #2
    Join Date
    Nov 2003
    Provided Answers: 23
    Select flname, flsaleamt, to_char(flsalesdate, 'yyyy-mm')
    from flsales 
    where extract(year from flsaledate) in (2015, 2016)
    order by flname, flsaledate
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags:

    Tips for good questions:

Posting Permissions

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