SQLScholar
Programmer
Hey all,
If i have a table (called table1). The columns are called `a` and `v`.
I want a query that sums all the values in `v` where the `a` col ='ab' then minus the ones that `ba`.
So i have a query like this
What i am getting is correct but i am getting the same amount of rows as currently in the table... i really only want one. How would i do this?
D
----------------------------------------
There are 2 types of computer, the prototype and the obsolete!!
If i have a table (called table1). The columns are called `a` and `v`.
I want a query that sums all the values in `v` where the `a` col ='ab' then minus the ones that `ba`.
So i have a query like this
Code:
SELECT 'total' AS Expr1, ((select sum(`v`) from table1 where a='ab')-(select sum(`v`) from table1 where a='ba')) AS Expr2
FROM table1
;
What i am getting is correct but i am getting the same amount of rows as currently in the table... i really only want one. How would i do this?
D
----------------------------------------
There are 2 types of computer, the prototype and the obsolete!!