Hi,
I was hoping for a query-based solution to the following problem. I already have a complicated mixed VBA/Report-based solution but it's becoming too cumbersome to manipulate.
I have a table [Invoices], where each record pertains to one invoice, e.g.:
Company / JobID / InvoiceNo / Final_Total
A ltd / JOB100 / INV-234 / £1000
A ltd / JOB100 / INV-567 / £4000
A ltd / JOB150 / INV-890 / £500
B ltd / JOB200 / INV-098 / £2000
I have a query [Summary] which groups all the invoices for each company and jobID (there are often multiple invoices per job), and that works fine using:
SELECT [Invoices].Company, [Invoices].jobID, Sum(IIf([status]='invoice',[final_total])) AS SumOfFinal_Total,
FROM [Invoices]
GROUP BY [Invoices].Company, [Invoices].job_no;
but I also need it to list all the invoice numbers for each company/jobID combination in each record and that's where I'm having trouble. Desired result would be:
Company / JobID / INVOICE1 / INVOICE2 / SumOfFinal_Total
A ltd / JOB100 / INV-234 / INV-567 / £5000
A ltd / JOB150 / INV-890 / / £500
B ltd / JOB200 / INV-098 / / £2000
Can anybody help? Thanks in advance.
I was hoping for a query-based solution to the following problem. I already have a complicated mixed VBA/Report-based solution but it's becoming too cumbersome to manipulate.
I have a table [Invoices], where each record pertains to one invoice, e.g.:
Company / JobID / InvoiceNo / Final_Total
A ltd / JOB100 / INV-234 / £1000
A ltd / JOB100 / INV-567 / £4000
A ltd / JOB150 / INV-890 / £500
B ltd / JOB200 / INV-098 / £2000
I have a query [Summary] which groups all the invoices for each company and jobID (there are often multiple invoices per job), and that works fine using:
SELECT [Invoices].Company, [Invoices].jobID, Sum(IIf([status]='invoice',[final_total])) AS SumOfFinal_Total,
FROM [Invoices]
GROUP BY [Invoices].Company, [Invoices].job_no;
but I also need it to list all the invoice numbers for each company/jobID combination in each record and that's where I'm having trouble. Desired result would be:
Company / JobID / INVOICE1 / INVOICE2 / SumOfFinal_Total
A ltd / JOB100 / INV-234 / INV-567 / £5000
A ltd / JOB150 / INV-890 / / £500
B ltd / JOB200 / INV-098 / / £2000
Can anybody help? Thanks in advance.
Last edited: