|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Putting SQL Statements together
I have 2 SQL queries (shown below) each is based on showing some information for a specific AssetID.
What I want to do is put both queries together into one specific grid result so that the Book value for the AssetID(Fig.1) and the Docamt for each AssetID(Fig.2) shows up in the same grid result. This sounds easy I think , but in Fig. 2 I have a statement which specifies that all docamt be shown that have a Descr = 'depreciation' however this cannot be the case with the bookamt values from this table as they do not have a descr that = 'depreciation' that have values that are unique in that field. Any ideas on how I can get these to come out in the same result such in this case? Any ideas appreciated regards Brick Fig. 1 Select xfaasset.assetid,xfaasset.descr1,xfaasset.divid,xf aasset.catid, Sum(xfadoc.bookamt) As Totbookamt from xfaasset Inner JOIN xfadoc On xfaasset.assetID = xfadoc.assetid where xfaasset.catid not like 'hel%' and xfaasset.perpurch < '200208' Group By xfaasset.assetid,xfaasset.descr1,xfaasset.divid,xf aasset.catid Fig.2 select xfadoc.assetid,xfaasset.divid,xfaasset.catid,xfaas set.descr1, sum(xfadoc.docamt) as TotalDep from xfadoc,xfaasset where xfadoc.assetid = xfaasset.assetid and xfadoc.descr = 'depreciation' and xfaasset.catid not like 'hel%' GROUP BY xfadoc.assetid,xfaasset.divid,xfaasset.catid,xfaas set.descr1 order by xfaasset.divid,xfaasset.catid,xfaasset.descr1, xfadoc.assetid desc |
|
#2
|
|||
|
|||
|
RE: Putting SQL Statements together
What Database System are you using?
|
|
#3
|
|||
|
|||
|
RE: Putting SQL Statements together
I wonder if he's tried subqueries.
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > Putting SQL Statements together |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|