Is there an elegant way to do this in MySQL:
SELECT (subquery1) AS s1, (subquery2) AS s2, (s1+s2) AS s3
or should I resort to
SELECT (subquery1) AS s1, (subquery2) AS s2, ((subquery1)+(subquery2)) AS s3
?
thanks
EDIT: both subqueries return integer results
You can use variables in MySQL
SELECT @query1:=(subquery) AS s1, @query2:=(subquery) AS s2, (@query1+@query2) AS s3
Still not so elegant. Perhaps you could develop subqueries so that we can offer better ways?
Source: https://habr.com/ru/post/1712269/More articles:C # - class for general connection to the database, command, reader - c #Tips for migrating from XPO to LINQ to SQL - linq-to-sqlSilverlight 3 BETA DataGrid Group - silverlightHow to filter strings in JTable? - javaselect multiple files in CFileDialog - mfcJRuby with Ruby 1.9 - ruby | fooobar.comlost field value after postback - javascriptis there a way to hold on to values? - lost in postback - javascriptVCDIFF for Java or alternative binary formats - javaDifference in usage between list and left join - optimizationAll Articles