|
-
Jan 17th, 2006, 04:21 PM
#1
Thread Starter
Junior Member
[SQL Query] any efficient way ?
hello,
(I am using MySQL) There i use SUM a lot of times.. so..
1.- the mysql engine is calculating each time the value of these
or
2.- use a cached value
is the answer is the 1st, is there any way more efficient than doin this query ??
sSQL = "SELECT "
sSQL = sSQL & "cue_id as 'Nro Cuenta', "
sSQL = sSQL & "cue_descripcion as 'Descripcion Cuenta', "
sSQL = sSQL & "SUM(IFNULL(asidet_debe,0)) as 'Debe', "
sSQL = sSQL & "SUM(IFNULL(asidet_haber,0)) as 'Haber', "
sSQL = sSQL & "IF(SUM(IFNULL(asidet_debe,0)) - SUM(IFNULL(asidet_haber,0)) > 0,SUM(IFNULL(asidet_debe,0)) - SUM(IFNULL(asidet_haber,0)),0) as 'Saldo Deudor', "
sSQL = sSQL & "IF(SUM(IFNULL(asidet_debe,0)) - SUM(IFNULL(asidet_haber,0)) < 0,SUM(IFNULL(asidet_haber,0)) - SUM(IFNULL(asidet_debe,0)),0) as 'Saldo Acreedor' "
sSQL = sSQL & "FROM "
sSQL = sSQL & "contab_cuentas_mayor LEFT JOIN contab_asientos_detalle "
sSQL = sSQL & "ON asidet_cue_id = cue_id "
sSQL = sSQL & "GROUP BY cue_id"
thanks in advance,
Ricardo
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|