travel-net
Posts: 56
|
Posted: 03/03/2004, 6:26 AM |
|
Hello,
I don't know how i must achieve the folliwing problem.
I wan't to add an extra label in a grid form which display's a value based on the following SQL code:
SELECT klant_tbl.klant_id, count(*),SUM(bedrag) AS totaal
FROM klant_abonn_tbl, klant_tbl, l_abonn_tbl
WHERE klant_tbl.mutatie_id <> 3
AND klant_abonn_tbl.mutatie_id <> 3
AND klant_abonn_tbl.klant_id=klant_tbl.klant_id
AND klant_abonn_tbl.abonn_id = l_abonn_tbl.abonn_id
AND klant_tbl.klant_id = klant_abonn_tbl.klant_id
GROUP BY klant_abonn_tbl.klant_id
This sql query is working.
The label should display totaal which stands for Amount in English
The grid itself has it's own sql based on the standard wizard from CCS.
Maybe there are severall ways to achieve this, but i don't now what is the best solution.
Regards,
Frans
|
|
|
johny_f
Posts: 23
|
Posted: 03/04/2004, 3:54 AM |
|
ADD Label before show event (not grid):
$db = new clsDBconnection-name(); // open coonection (replace "connection-name" with the real name of your connection used by CCS
$SQL = "SELECT klant_tbl.klant_id, count(*),SUM(bedrag) AS totaal
FROM klant_abonn_tbl, klant_tbl, l_abonn_tbl
WHERE klant_tbl.mutatie_id <> 3
AND klant_abonn_tbl.mutatie_id <> 3
AND klant_abonn_tbl.klant_id=klant_tbl.klant_id
AND klant_abonn_tbl.abonn_id = l_abonn_tbl.abonn_id
AND klant_tbl.klant_id = klant_abonn_tbl.klant_id
GROUP BY klant_abonn_tbl.klant_id";
// I think you shoul remove Group by to get only apropriete number for selected row
$db->query($SQL);
$xcount = $db->num_rows(); //num of rows if you wish
$Result= $db->next_record(); // get record
if ($Result)
{
$c_id = $db->f("db_fieldname"); // get certain field from DB
}
unset($db);
// set value do label
$gridname->labelname->SetValue($c_id);
I hope this is clear, I persume you want to display diff. single result for each row of the grid.
Johny_f
_________________
Johny_f |
|
|
|