Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 22nd, 2005, 01:27 PM
Registered User
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default SubQuery totalling

I have created a monster!

The following (is not pretty but) produces a query successfully: I have inserted carriage returns to aid readability.

I now need to provide a report in access that has a Grand Total of the Total O/S column at the report footer, but am getting Group By errors.

Have tried to use DSum instead of a subquery in the SQL but cannot get this to work in place of the existing sub queries.

Can anyone spot any howling errors or make any suggestions. Will DSum be my answer? Am sorry if I have not explained too clearly but am tired after long day. If clarification needed please ask. Thank you.

SELECT
Analysis_owner.Manager,
quo.CCS_QUO_ANALYSIS_CODE AS AnaCode,
quo.[CCS_QUO_REF_NUMBER#1] AS RefNo1,
quo.[CCS_QUO_REF_NUMBER#2] AS RefNo2,
quo.[CCS_QUO_ADDRESS#1] AS Project,
quo.CCS_QUO_COST_YTD AS CostYTD,
quo.[CCS_QUO_COST_PRICE#6] AS Income,

(SELECT SUM(Nz(sil.[CCS_SIL_TOTAL],0)-Nz(sil.[CCS_SIL_VAT],0)) FROM CONSTRUCT_CCS_S_INVOICE_LINE sil WHERE quo.[CCS_QUO_QUOTE_NUMBER] = sil.[CCS_SIL_QUOTE_NUMBER] AND sil.[CCS_SIL_INV_MODE] Not Like '5' AND sil.[CCS_SIL_INV_MODE] Not Like '8' AND sil.[CCS_SIL_POSTED] <> 3) AS InvoiceExVAT,

(SELECT ROUND(SUM(trans.[ALLOCATED_AMOUNT])/1.175,2) FROM [ACCOUNTING_SYSTEM_SALES_TRANSACTIONS] trans, [CONSTRUCT_CCS_S_INVOICE_LINE] sil WHERE trans.[UNIQUE_REFERENCE_NO] =sil.[CCS_SIL_UNIQUE_REF_NO] AND quo.[CCS_QUO_QUOTE_NUMBER] =sil.[CCS_SIL_QUOTE_NUMBER]) AS ['Cash Recd'],

Round(Nz([InvoiceExVAT],0)-Nz(['Cash Recd'],0),2) AS ['Cash O/S'],
Round(Nz([ACCRUED_INC],0),2) AS ['Accrued Inc'],
Round(Nz([WIP],0),2) AS ['WIP'],
CCur((Nz(['Cash O/S'],0)+Nz(['Accrued Inc'],0)+Nz(['WIP'],0))) AS ['Total O/S']

FROM (CONSTRUCT_CCS_QUOTES AS quo INNER JOIN MONTHLY_PL ON quo.CCS_QUO_QUOTE_NUMBER=MONTHLY_PL.QUOTE_NUMBER) INNER JOIN Analysis_owner ON quo.CCS_QUO_ANALYSIS_CODE=Analysis_owner.Analysis_ code;



Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Subquery debbiecoates SQL Server 2000 4 June 25th, 2008 03:49 AM
Subquery as table brettk_1 Oracle 1 January 22nd, 2007 02:10 PM
Do i have to use a subquery, if yes then how? code_lover SQL Language 2 January 2nd, 2007 02:22 PM
subquery khansa MySQL 1 February 21st, 2006 02:49 AM
Sub Totalling ppenn Excel VBA 3 April 22nd, 2004 11:09 AM



All times are GMT -4. The time now is 10:55 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.