![]() |
Query help
I have a table with (for simplification) three columns: fromuserid, touserid, and amount. I want to find the sum of amount, but it is governed by the following (using 13 as a sample userid):
|
Why not do your calculations outside of the query using PHP - makes for faster processing time :)
|
[SQL]SELECT SUM(IF(fromuserid = 13, -1, 1)) FROM table WHERE fromuserid = 13 OR touserid = 13[/sql]
that should work i think |
Quote:
[sql] SELECT sum(IF(touserid = 13, amount, - amount)) FROM turtledollar WHERE touserid = 13 OR fromuserid = 13 [/sql] |
oops, i forgot that you ahve a special col with the ammount ;)
|
All times are GMT. The time now is 10:07 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|