sort-filter-on-sql-sum-field

Questionssort-filter-on-sql-sum-field
Willy Hendrickx asked 1 week ago

Hello, I use the following SQL-statement to retrieve my data :

SELECT reizentbl.PK_Reizen, reizentbl.Reis, reizentbl.AfreisDatum, reizentbl.TerugReis, reizentbl.TypeReis_ID, reizentbl.AantalBegeleiders, reizentbl.Paspoort, reizentbl.Opmerking, reizentbl.Aantal, reizentbl.PO, Sum(temptbl.Bevestigd) AS SomVanBevestigd FROM reizentbl INNER JOIN temptbl ON reizentbl.PK_Reizen = temptbl.Reis_ID WHERE ((DATE(reizentbl.TerugReis) >= SUBDATE(CURDATE(), 0)) AND reizentbl.Reis NOT LIKE \’%Logistiek%\’) GROUP BY reizentbl.Reis, reizentbl.AfreisDatum, reizentbl.TerugReis\”;

As you can see I use the SUM functions in my SQL-statement. Initially my grid is sorted on the \”reizentbl.AfreisDatum\”.

After I load my grid it would be very useful sometimes to filter or sort my grid data so I could see the data where my SUM value is ZERO and still sorted on \”reizentbl.AfreisDatum\”

In my grid : I have tried the sort function on the SUM field but then my sort on \”reizentbl.AfreisDatum\” disappears.

I have tried the filter function on the SUM field but then I receive an SQL-error on the SUM field. How can I solve this problem? Kind regards Willy

1 Answers
Abu Ghufran Staff answered 7 hours ago

You can enable multisort option. e.g.

$opt[“multiSort”] = true;
//…
$g->set_options($opt);

After that, clicking of column will have 3 states. ASC, DESC, NONE.
You can sort one column as ASC and then click of second column to make it ASC/DESC as well.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

3 + 6 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?