Subject | Re: [firebird-support] Help needed in complex query |
---|---|
Author | Milan Babuskov |
Post date | 2006-08-09T15:22:48Z |
kiran.gutta@... wrote:
application and print it.
In, PHP it's as simple as:
select printerid, papersize, usergroup, userid, count(*)
from ...
where ...
group by printerid, papersize, usergroup, userid
while ($row = fetch())
{
$data[$row->USERGROUP.':'.$row->USERID][
$row->PRINTERID.':'.$row->PAPERSIZE] = $row->COUNT;
}
For printout, use something like:
foreach ($data as $rows)
{
// print header
foreach ($data[$rows] as $columns)
// output cell
// output totals
}
--
Milan Babuskov
http://swoes.blogspot.com/
http://www.flamerobin.org
> I have the following tables.In such cases, I usually build a 2-dimensional in-memory array in client
> PRINTLOG - contains : USERID, PRINTERIP, PAGES, PAPERSIZE,PAPERTYPE,
> PRINTERS - Contains : PRINTERID, PRINTERIP
> PRINTERGROUPS - Contains : GROUPID, PRINTERID
> USERGRROUPS - Contains : GROUPID, USERID
>
> Using the above information, I need to display a report of Total Pages
> printed by each user on each printer for the selected User Group and
> Printer Group as shown below.
application and print it.
In, PHP it's as simple as:
select printerid, papersize, usergroup, userid, count(*)
from ...
where ...
group by printerid, papersize, usergroup, userid
while ($row = fetch())
{
$data[$row->USERGROUP.':'.$row->USERID][
$row->PRINTERID.':'.$row->PAPERSIZE] = $row->COUNT;
}
For printout, use something like:
foreach ($data as $rows)
{
// print header
foreach ($data[$rows] as $columns)
// output cell
// output totals
}
> Please help me about how to write query /view to get the data inHaving variable number of columns is impossible in SQL query.
> required format.
--
Milan Babuskov
http://swoes.blogspot.com/
http://www.flamerobin.org