Subselect and sum row Default theme
Subselect() will create a new column with some value from other (or current) table. You can use any columns from current tables as parameters. Subselect will be called for each row
HIDE CODE
<?php
$xcrud = Xcrud::get_instance();
$xcrud->table('customers');
$xcrud->columns('customerName,city,creditLimit,Paid,Profit'); // specify only some columns
$xcrud->subselect('Paid','SELECT SUM(amount) FROM payments WHERE customerNumber = {customerNumber}'); // other table
$xcrud->subselect('Profit','{Paid}-{creditLimit}'); // current table
$xcrud->sum('creditLimit,Paid,Profit'); // sum row(), receives data from full table (ignores pagination)
$xcrud->change_type('Profit','price','0',array('prefix'=>'$')); // number format
echo $xcrud->render();
?>
Customers
Add Export into CSV Print Search
| # | Customername | City | Creditlimit | Paid | Profit | |
|---|---|---|---|---|---|---|
| 1 | La Rochelle Gifts | Nantes | 118200 | $0.00 | View Edit Remove | |
| 2 | Baane Mini Imports | Stavern | 81700 | 274.52 | $-81,425.48 | View Edit Remove |
| 3 | Mini Gifts Distributors Ltd. | San Rafael | 210500 | $0.00 | View Edit Remove | |
| 4 | Havel & Zbyszek Co | Warszawa | 0 | $0.00 | View Edit Remove | |
| 5 | Blauer See Auto, Co. | Frankfurt | 59700 | 111 | $-59,589.00 | View Edit Remove |
| 6 | Mini Wheels Co. | San Francisco | 64600 | 0 | $-64,600.00 | View Edit Remove |
| 7 | Land of Toys Inc. | NYC | 114900 | 0 | $-114,900.00 | View Edit Remove |
| 8 | Euro+ Shopping Channel | Madrid | 227600 | 63843.54 | $-163,756.46 | View Edit Remove |
| 9 | Volvo Model Replicas, Co | Lula | 53100 | 63843.54 | $10,743.54 | View Edit Remove |
| 10 | Danish Wholesale Imports | Kobenhavn | 83400 | 25275.59 | $-58,124.41 | View Edit Remove |
| Σ | 8044300.12 | 6688705.560000002 | $-1,026,894.56 |
?>