If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Error while Concatinating

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-10-12, 02:25
deb_84 deb_84 is offline
Registered User
 
Join Date: Nov 2011
Posts: 7
Error while Concatinating

Hi,
When i running this query
select (select count(*) from locations) + (select count(*) from regions) as "Total" from dual ... It's working fine.

But i need to add one more column SUM(Amount) which will fetch the total amount. So i changed the query to
select (select SUM(AMT),count(*) from locations) + (select SUM(AMT),count(*) from regions) as "Total" from dual. I am getting to many values error.

What needs to be done for this?
Reply With Quote
  #2 (permalink)  
Old 01-10-12, 02:35
JarlH JarlH is offline
Registered User
 
Join Date: Dec 2008
Location: At work...
Posts: 68
Try:

select SUM(AMT), count(*)
from
(select amt from locations
union all
select amt from regions)
Reply With Quote
  #3 (permalink)  
Old 01-10-12, 02:49
deb_84 deb_84 is offline
Registered User
 
Join Date: Nov 2011
Posts: 7
Hi Jarl

Thnaks A lot it's working now !!!!
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 On
Pingbacks are On
Refbacks are On