Member Login

Freestyle Joomla Forums

Includes: Data

Member Login   Register

Please login or register to post on the forum

Forum Index    Board Index    Last Post   

Michael Norton

Michael Norton

08 October 2015, 04:42

SQL query question

Hi, I have managed to display two calculated values from unrelated tables as per
 
SELECT
(SELECT SUM( transactions.amount ) FROM transactions) AS ammount_total,
(SELECT '110' * DATEDIFF( CURDATE( ) , controls.start ) FROM controls) AS budget
 
This works and displays both values.
 
I would like to subtract one value from the other and display this result amount only as per
 
budget-amount_total
 
Can you help with this one?
 
I have tried to use UNION and JOIN but as the tables are unrelated I am not having much luck and would appreciate your input.
 
regards
 
Michael
Link showing problem http://www.nortonsplace.com/budget/dashboard
Joomla Version 3.4.1
Freestyle Version 2.8.0.2014
Pro/Lite Pro
Adam Clarke

Adam Clarke

08 October 2015, 10:31

Re: SQL query question

Hello

Im not 100% sure, but you should be able to do:

SELECT
(SELECT SUM( transactions.amount ) FROM transactions) AS ammount_total,
(SELECT '110' * DATEDIFF( CURDATE( ) , controls.start ) FROM controls) AS budget,

(budget - ammount_total) as somename

Thanks

Adam Clarke
Freestyle Joomla

Vote For Us!

Please vote for our software or write a review of one of our products on the Joomla! Extensions Directory