Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2014

    Unanswered: Apportioning data into multiple columns


    I am quite new to SQL so was wondering if you could help me.

    I currently have

    select c.code,, d.date_previous,CAST( as int) as Days, d.units, d.cost
    from table1 as d
    inner join table2 as p
    on d.ID = p.ID
    inner join table3 as c
    on p.c_id = c.ID
    where date_previous > '31/12/2012'

    This is bringing back one row per invoice received after 31/12/2012. The aim is to get the following:

    Code Jan data Feb data Mar data

    > one unique code per line (so I'm assuming row partitioning is required)
    > Where a bill has a period of 3 months with, for example, 300 units, I'd like that separated out across 3 months (100 in each)

    I'm aware I'd probably need to use a pivot function and some temp tables but I'm not that advanced yet.

    Any help would be appreciated.

    Last edited by thoron6; 06-27-14 at 06:25.

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jun 2014
    Thanks! I'll see if I can implement that. Any ideas how to apportion the units per month?

    Thanks again

Tags for this Thread

Posting Permissions

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