I have been trying to figure out how to create a Union Query between two tables with different data with one field containing similiar data.
I have 2 tables:
NoteData & IndirectData
The common field (although named differently in the two tables) contains TaxID information. I am triying to do Sum calculations at the same time in the qury and that may be my probelm. See below: - SELECT TreevNoteData.Account_Primary_Borrower_Tax_ID_Nbr AS TaxID,
-
Sum(TreevNoteData.Note_Current_Balance) AS SumOfNote_Current_Balance,
-
Sum(TreevNoteData.Note_Ledger_Balance) AS SumOfNote_Ledger_Balance,
-
Sum(TreevNoteData.Note_Appraisal_Value) AS SumOfNote_Appraisal_Value,
-
Sum(IIf(Len([TreevNoteData]![Note_Collateral_Code])=2,IIf([TreevNoteData]![Note_Collateral_Code]="A1",[TreevNoteData]![Note_Ledger_Balance],0),[TreevNoteData]![Note_Ledger_Balance])) AS [Unsecured Bal],
-
Sum(IIf([TreevNoteData]![Note_Type_Code] In ("100","101","190","402"),IIf(Len([TreevNoteData]![Note_Collateral_Code])=2,IIf([TreevNoteData]![Note_Collateral_Code]="A1",[TreevNoteData]![Note_Ledger_Balance],0),[TreevNoteData]![Note_Ledger_Balance]),0)) AS ComUnsecBal,
-
Sum(IIf([TreevNoteData]![Note_Type_Code] In ("100","101","190","402"),[TreevNoteData]![Note_Ledger_Balance],0)) AS ComBal,
-
NULL,
-
NULL
-
FROM TreevNoteData
-
UNION ALL
-
SELECT TreevIndirectData.Endr_Customer_Tax_ID_Number AS TaxID,
-
Sum(TreevIndirectData.Indirect_Liab_Limit_Amount) AS SumOfIndirect_Liab_Limit_Amount,
-
Sum(TreevIndirectData.Indirect_Liab_Limit_Percent) AS SumOfIndirect_Liab_Limit_Percent,
-
Sum(TreevIndirectData.Note_Cmmt_Bank_Share_Ledger_Balance) AS SumOfNote_Cmmt_Bank_Share_Ledger_Balance,
-
Sum(TreevIndirectData.Note_Cmmt_Current_Balance) AS SumOfNote_Cmmt_Current_Balance,
-
Sum(TreevIndirectData.Note_Cmmt_Ledger_Balance) AS SumOfNote_Cmmt_Ledger_Balance,
-
Sum(TreevIndirectData.Note_Cmmt_Original_Credit_Line_Amt) AS SumOfNote_Cmmt_Original_Credit_Line_Amt,
-
Sum(TreevIndirectData.Note_Cmmt_Unused_Credit_Line_Amount) AS SumOfNote_Cmmt_Unused_Credit_Line_Amount,
-
Sum(TreevIndirectData.Note_Cmmt_Used_Credit_Line_Amount) AS SumOfNote_Cmmt_Used_Credit_Line_Amount FROM TreevIndirectData
-
GROUP BY TaxID;
1 1440 NeoPa 32,556
Expert Mod 16PB
I suggest you find a cut-down version which exhibits the same symptoms that you want help with. Most of this SQL is entirely unrelated to your question so expecting others to wade through this just to find your problem is not reasonable.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: jtwright |
last post by:
I've got a view that creates a parent child relationship, this view is
used in Analysis Services to create a dimension in a datastore. This
query tends to deadlock after about 10 days of running...
|
by: edself |
last post by:
Greetings,
I am semi-new to Access and have a query question. I presume the solution
is easy, but need some help.
I have created a database with a Contact table. The contact table contains...
|
by: Jamal |
last post by:
I am working on binary files of struct ACTIONS
I have a recursive qsort/mergesort hybrid that
1) i'm not a 100% sure works correctly
2) would like to convert to iteration
Any comments or...
|
by: CrystalDBA |
last post by:
I usually design applications in SQL Server and Crystal Reports. I
now need to create a crystal report on an MS Access database.
I have two tables:
Services:
Date datetime
Entry text...
|
by: Jeremy |
last post by:
I have a situation where i am trying to run two query's and retrieve
one record from each query, then using Union combine them into one
recordset. The First Query is strait forward and should just...
|
by: rcamarda |
last post by:
I wish to build a table based on values from another table.
I need to populate a table between two dates from another table. Using
the START_DT and END_DT, create records between those dates.
I...
|
by: BillCo |
last post by:
I've encountered a problem while using ADO to save query objects.
Union queries created normally (via the interface) appear in adox
catelog.procedures rather than catelog.views. This is reasonably...
|
by: wugon.net |
last post by:
question: db2 LUW V8 UNION ALL with table function month() have bad
query performance
Env:
db2 LUW V8 + FP14
Problem :
We have history data from 2005/01/01 ~ 2007/05/xx in single big...
|
by: pbd22 |
last post by:
Hi.
I really need some advice on fine-tuning a stored procedure
that is the meat of the search logic on my site. Customers
are allowed to save searches, which dumps the search logic
in a table...
|
by: rj041284 |
last post by:
i have completed these q. in sql but unable to do it in pl/sql let me help or give me path to do it
Exercises :
Q 1) Display department number and sum of the salaries of employees...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |