The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
![]()
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):
|
#2
|
||||
|
||||
![]()
Why not do your calculations outside of the query using PHP - makes for faster processing time
![]() |
#3
|
||||
|
||||
![]()
[SQL]SELECT SUM(IF(fromuserid = 13, -1, 1)) FROM table WHERE fromuserid = 13 OR touserid = 13[/sql]
that should work i think |
#4
|
|||
|
|||
![]() Quote:
[sql] SELECT sum(IF(touserid = 13, amount, - amount)) FROM turtledollar WHERE touserid = 13 OR fromuserid = 13 [/sql] |
#5
|
||||
|
||||
![]()
oops, i forgot that you ahve a special col with the ammount
![]() |
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|