Hi everyone

i need some help down here. i am trying to connect multiple db and at the same time i want to sum the value of the column. what i have right now is this

SELECT SUM(total) as branch1sales FROM icm.sales 
UNION 
SELECT sum(total) as branch2sales FROM hism.sales

its computing correctly but the problem is the branch2 alias is being invoke. what am i doing wrong? see attached image for the output

Untitled.jpg

thanks

Recommended Answers

All 2 Replies

Try

SELECT  (SELECT SUM(total) FROM icm.sales)  AS branch1_sales,
        (SELECT SUM(total) FROM hism.sales) AS branch2_sales

@ Revjim

thank you so much for that Snippet it really do the trick. learned new thing today and i cant believe that it is possible to access other db's with out using union or some other techniques

thanks

Neil

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.