473,385 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

problem with the query

Hi
I have query here through which Im actually trying to prepare a report .

SELECT
DEAL_DETAIL.DEAL_ID, DEAL_DETAIL.CURRENCY_CODE,DEAL_DETAIL.RATE,
DEAL_DETAIL.CURRENCY_AMOUT,DEAL_DETAIL.SETTLEMENT_ AMOUNT,
convert(varchar , DEAL_DETAIL.CREATED_DATE , 120) CREATED_DATE ,
CUSTOMER.COMPANY_NAME,PAYMENT_FUNDS_IN.AMOUNT,
(select sum(amount)as total from PAYMENT_FUNDS_IN ,DEAL_DETAIL where DEAL_DETAIL.DEAL_ID=PAYMENT_FUNDS_IN.DEAL_ID group by DEAL_DETAIL.CURRENCY_CODE )
FROM DEAL_DETAIL,CUSTOMER ,PAYMENT_FUNDS_IN
where DEAL_DETAIL.CUSTOMER_ID=CUSTOMER.CUSTOMER_ID AND DEAL_DETAIL.DEAL_ID=PAYMENT_FUNDS_IN.DEAL_ID


In this DEAL_DETAIL , PAYMENT_FUNDS_IN and CUSTOMER are three different tables
I have no problem with the main query.But in my report I have show the total of amount for each currency
so I wrote the sub query.when it is executed separatley it works fine but when i put as a part of main query im getting the following error
deal_id is the common column in DEAL_DETAIL , PAYMENT_FUNDS_IN and CUSTOMER

please suggest

Thanks In Advance
Sep 29 '08 #1
2 968
deepuv04
227 Expert 100+
Hi,
Try the following query probably will work for you,

[code=sql]
SELECT
D_D.DEAL_ID, D_D.CURRENCY_CODE,D_D.RATE,
D_D.CURRENCY_AMOUT,D_D.SETTLEMENT_ AMOUNT,
convert(varchar , D_D.CREATED_DATE , 120) CREATED_DATE ,
CUSTOMER.COMPANY_NAME,PAYMENT_FUNDS_IN.AMOUNT,
(select sum(amount)as total
from PAYMENT_FUNDS_IN ,
DEAL_DETAIL
where DEAL_DETAIL.DEAL_ID=PAYMENT_FUNDS_IN.DEAL_ID AND
DEAL_DETAIL.CURRENCY_CODE = D_D.CURRENCY_CODE )
FROM DEAL_DETAIL as D_D,CUSTOMER ,PAYMENT_FUNDS_IN
where D_D.CUSTOMER_ID=CUSTOMER.CUSTOMER_ID AND D_D.DEAL_ID=PAYMENT_FUNDS_IN.DEAL_ID
[/sql]
Thanks
Sep 29 '08 #2
Hi,
Try the following query probably will work for you,

[code=sql]
SELECT
D_D.DEAL_ID, D_D.CURRENCY_CODE,D_D.RATE,
D_D.CURRENCY_AMOUT,D_D.SETTLEMENT_ AMOUNT,
convert(varchar , D_D.CREATED_DATE , 120) CREATED_DATE ,
CUSTOMER.COMPANY_NAME,PAYMENT_FUNDS_IN.AMOUNT,
(select sum(amount)as total
from PAYMENT_FUNDS_IN ,
DEAL_DETAIL
where DEAL_DETAIL.DEAL_ID=PAYMENT_FUNDS_IN.DEAL_ID AND
DEAL_DETAIL.CURRENCY_CODE = D_D.CURRENCY_CODE )
FROM DEAL_DETAIL as D_D,CUSTOMER ,PAYMENT_FUNDS_IN
where D_D.CUSTOMER_ID=CUSTOMER.CUSTOMER_ID AND D_D.DEAL_ID=PAYMENT_FUNDS_IN.DEAL_ID
[/sql]
Thanks


Thank You very much that helped me a lot
Sep 30 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Brian Oster | last post by:
After applying security patch MS03-031 (Sql server ver 8.00.818) a query that used to execute in under 2 seconds, now takes over 8 Minutes to complete. Any ideas on what the heck might be going...
8
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
4
by: Apple | last post by:
1. I want to create an autonumber, my requirement is : 2005/0001 (Year/autonumber), which year & autonumber no. both can auto run. 2. I had create a query by making relation to a table & query,...
6
by: lenny | last post by:
Hi, I've been trying to use a Sub or Function in VBA to connect to a database, make a query and return the recordset that results from the query. The connection to the database and the query...
3
by: StBond | last post by:
Hi everyone, I am new to Access and Visual Basic so things my be getting across a bit cloudy. I only started using VB for one week. I am having a little problem with the database that I am...
3
by: Andy_Khosravi | last post by:
I have been trying to build a user friendly search engine for a small database I have created. I'm having some particular problems with one of my date fields. Here's the setup: I'm using...
20
by: Development - multi.art.studio | last post by:
Hello everyone, i just upgraded my old postgres-database from version 7.1 to 7.4.2. i dumped out my 7.1 database (with pg_dump from 7.1) as an sql-file with copy-commands and to one file using...
0
by: mjsterz | last post by:
I've been working with VB .NET for less than a year and this is the first time I've posted on one of these groups, so let me apologize beforehand if I'm being unclear, not posting my issue...
3
by: Juan Antonio Villa | last post by:
Hello, I'm having a problem replicating a simple database using the binary log replication, here is the problem: When the master sends an update to the slave, an example update reads as follows:...
9
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
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...
0
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.