Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8867947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:09:17+00:00 2026-06-14T17:09:17+00:00

I have two tables Projects and Invoices. The database is MS Access ( mdb

  • 0

I have two tables Projects and Invoices. The database is MS Access ( mdb )

Project table has fields

  1. ProjectID
  2. ProjectName
  3. ProjectStatus

Invoices table has the fields

  1. InvoiceID
  2. ProjectID ( foreign key )
  3. InvoiceType ( Paid and Recieved )
  4. InvoiceChannel ( Coding, Designing and Consulting )
  5. InvoiceAmount

The Projects table is in a one-to-many relation with Invoices table with Project ID as foreign key.

I want a table created from querying the Invoices table like this

Grouping problem in MS Access

How can I achieve this using an SQL query?
Or do I have to do it using server side coding ( I use C# with ASP.NET )

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:09:18+00:00Added an answer on June 14, 2026 at 5:09 pm

    Your posted table schema doesn’t have a field that contains the amount to sum. I will refer to it as Amount.

    First, create a crosstab query, and save it in the database (I’ve called it ct):

    TRANSFORM Sum(Amount) AS SumOfAmount
    SELECT ProjectID, InvoiceType
    FROM Invoices
    GROUP BY ProjectID, InvoiceType
    PIVOT InvoiceChannel In ("Coding","Designing","Consulting");
    

    This will give you the ProjectID and the InvoiceType as the first two columns, with one additional column each for “Coding”,”Designing” and “Consulting”.

    To get the total, you need another query:

    SELECT ct.*, Coding + Designing + Consulting AS Total
    FROM ct;
    

    Bear in mind that if there are no records for a particular ProjectID/InvoiceType/InvoiceChannel, the query will return NULL for that combination, which will result in the Total being NULL. If this query will be running under Access (say via Access.Application) you can use the Nz function, which works like the ?? operator in C#:

    SELECT ct.*, Nz(Coding,0) + Nz(Designing,0) + Nz(Consulting,0) AS Total
    FROM ct;
    

    If you are accessing data from an .mdb or .accdb via ADO.NET using the OleDbProvider, you probably won’t be able to use Nz, and you’ll have to use something more complex:

    SELECT ct.*, 
        Iif(IsNull(Coding), 0, Coding) +
        Iif(IsNull(Designing), 0, Designing) + 
        Iif(IsNull(Consulting), 0, Consulting) AS Total
    FROM ct;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi all i have two tables Projects ---------- ProjectID|ProjectNAme 1 |asdasd 2 |adas 3
I have two tables, tasks and projects. And every task has a project (and
I have two tables: projects and tasks. A project consists of tasks. I want
I have two tables: entitytype and project . Here are the create table statements:
I have two tables: one called Projects, and another called Documents (projects has many
I have two tables in which the second table has a foreign key which
I have a database that has two tables, one of which contains a foreign
I have two tables an employee table and a project table and I am
I have two tables... project table +----+--------+ | id | client | +----+--------+ |
I have two models (and tables) in my Rails project. Each model has an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.