Results 1 to 5 of 5
  1. #1
    peter_lawton is offline Novice
    Windows XP Access 2002
    Join Date
    Sep 2009
    Location
    London
    Posts
    29

    Songwriter Conundrum - How do I calculate this please?


    If any one can come up with a better subject title I will repost. Thanks

    I have been collecting income from Harry Fox (a collection agency for money generated by record sales) for three songwriters (33.3% each). I divide the income into three and pay them. An easy enough calculation.

    However one of the writers now gets paid directly so I only collect on behalf of two of them.

    The table structure is
    a) SongID
    b) junction table SongID / WriterID / ShareID
    c) WriterID
    d) ShareID

    A simple example might be

    001 Elephant Song

    101 Fred Smith Collected by Me
    102 John Brown Collected by Me
    103 Bert Jones Collected Directly

    201 33.3%

    One to many joins as appropriate.

    Before I could just split the income according to the Writer’s Share but now, although the share of the Song remains thirds I have to distribute the income I collect 50/50 between two of the Writers.

    The fields for ‘Writer Share of Song’ and ‘Who Collects’ already exist. I could create a new field for Writer Share of Income but was curious to see if there was a way of calculating ‘Total No of Writers’ divided by ‘Number of Writers for Whom I Collect’ using the structure I already have.

    Even as an intellectual puzzle I'd be very interested in any possible solutions as it impacts on my database designs generally.

    Thanks peter

  2. #2
    jzwp11 is offline VIP
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You should be able to calculate what you need. You'll need a couple of counting queries combined into a third query.

    First, a query to get the number of writers for each song.

    query name: qryCountOfWriters
    SELECT songID, count(writerID) as TotalNumberOfWriters
    FROM yourjunctiontable
    GROUP BY songID

    Assuming that the Who Collects field is in the writers table
    query name: qryListOfWritersForWhomICollect
    SELECT writerID
    FROM writerTable
    WHERE WhoCollects="Collected by Me"

    query name: qryCountOfWritersForWhomICollect
    SELECT songID, Count(writerID) as TotalNumberForWhomICollect
    FROM yourjunctiontable inner join qryListofWritersForWhomICollect on yourjunctiontable.writerID=qryListOfWriterForWhomI collect.writerID
    GROUP BY songID

    ...but was curious to see if there was a way of calculating ‘Total No of Writers’ divided by ‘Number of Writers for Whom I Collect’ using the structure I already have


    I'm not sure what the ratio: [Total No of Writers]/[Number of Writers for Whom I collect] will tell you. Let's say a song has 3 writers but you only collect for two of them; your expression would be 3/2 or 1.5. Wouldn't just the total # of writers (3) and the number for whom I collect (2) be sufficient to tell you that you have to split the funds between 2 people?

    If that is the case, just bring the two counting queries together as follows:

    SELECT qryCountOfWriters.songID, qryCountOfWriters.TotalNumberOfWriters, IIF (isnull(qryCountOfWritersForWhomICollect.TotalNumb erForWhomICollect),0,qryCountOfWritersForWhomIColl ect.TotalNumberForWhomICollect) as MyWritersForWhomICollect
    FROM qryCountOfWriters left join qryCountOfWritersForWhomICollect on qryCountOfWriters.SongID=qryCountOfWritersForWhomI Collect.SongID

  3. #3
    peter_lawton is offline Novice
    Windows XP Access 2002
    Join Date
    Sep 2009
    Location
    London
    Posts
    29
    Thanks very much - I'd forgotten about the count function. Haven't used it before. I'll give a try today.

  4. #4
    peter_lawton is offline Novice
    Windows XP Access 2002
    Join Date
    Sep 2009
    Location
    London
    Posts
    29
    worked a treat, thank you very much

    peter

  5. #5
    jzwp11 is offline VIP
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Glad it worked out for you! Good luck with your database.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Calculate Interest
    By jgelpi16 in forum Queries
    Replies: 3
    Last Post: 08-19-2016, 08:01 PM
  2. calculate value from two tables
    By victor in forum Programming
    Replies: 3
    Last Post: 08-20-2010, 12:13 PM
  3. Replies: 5
    Last Post: 05-05-2010, 04:31 PM
  4. Calculate avg in a report
    By bob006 in forum Reports
    Replies: 1
    Last Post: 11-18-2009, 06:31 PM
  5. calculate holidays
    By barkarlo in forum Queries
    Replies: 0
    Last Post: 12-20-2006, 06:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums