Results 1 to 5 of 5
  1. #1
    sr1811 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    2

    Generating age wise report of sundry debtors


    I have a database consisting of bill number, bill date. Current no of days outstanding is derived out of datediff("d",bill date,now). I wants to generate different columns for less than one year, 1 to 2 years, 2-3 years etc of bills outstanding. Please help me do the same by using sub queries.

    regards

    SR

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    Post your current SQL statement so that a viable solution can be provided that matches your particular needs.

  3. #3
    sr1811 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    2
    Hi

    There are two table Customer with Customer ID and Customer Name and Order with Customer ID,Order ID, Order Date and Payment Date

    I am looking for a multiple result in different columns. The SQL looks like:
    SELECT Customer.[Customer ID],
    SELECT(Order.[Amount] FROM Order WHERE DateDiff("d",[Order Date],Now) < 90 AND Order.[Payment Date] is NULL AND Customer.[Customer ID] = Order[Customer ID] As [Less than 90],
    (SELECT(Order.[Amount] FROM Order WHERE DateDiff("d",[Order Date],Now) < 180 AND Order.[Payment Date] is NULL AND Customer.[Customer ID] = Order[Customer ID] As [Less than 180],
    (SELECT(Order.[Amount] FROM Order WHERE DateDiff("d",[Order Date],Now) < 360 AND Order.[Payment Date] is NULL AND Customer.[Customer ID] = Order[Customer ID] As [Less than 360],

    regards

    SR1811

  4. #4
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    I did this with four queries.

    See the attached database. I created a query for each of the particular agings and then created a UNION query to join them
    Attached Files Attached Files

  5. #5
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    This will get you your different date ranges in a single query.
    Code:
    SELECT 
       TC.[Customer ID],
       IIF(DateDiff("d",T2.[Order Date],Now) < 90, T2.[Amount],0) AS [Less than 90],
       IIF(DateDiff("d",T2.[Order Date],Now) BETWEEN 90 and 179, T2.[Amount],0) AS [Less than 180],
       IIF(DateDiff("d",T2.[Order Date],Now) BETWEEN 180 and 359, T2.[Amount],0) AS [Less than 360],
    ... etc ...
    FROM
       tblCustomer AS TC 
       INNER JOIN 
       tblOrder as T2 
       ON TC.[Customer ID] = T2.[Customer ID];
    Note that I have changed your table names, since ORDER is a reserved word. It's also best to avoid spaces in field names, but I've left those alone.

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

Similar Threads

  1. Generating Report from Form filtering
    By oica72 in forum Reports
    Replies: 5
    Last Post: 12-17-2011, 05:35 PM
  2. Help on Generating a Report!
    By ETCallHome in forum Reports
    Replies: 10
    Last Post: 06-22-2011, 01:08 PM
  3. Form using requerys and report generating
    By kroenc17 in forum Forms
    Replies: 1
    Last Post: 09-22-2010, 07:12 AM
  4. Generating Report from Form
    By mwabbe in forum Reports
    Replies: 8
    Last Post: 08-30-2010, 12:25 PM
  5. noob prob, generating next report
    By flash319 in forum Reports
    Replies: 2
    Last Post: 08-04-2008, 03:10 PM

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