Subject | Re: [firebird-support] Looping Query to count checkouts |
---|---|
Author | Thomas Clarke |
Post date | 2011-06-18T13:02:57Z |
On Fri, Jun 17, 2011 at 10:29 PM, John <javakqj@...> wrote:
How about:
select a."Personnel_ID", count(*) as check_out_cnt
from "AssetHistory" a
where
a."EntryType" = 'CheckOut'
group by a."Personnel_ID"
This will count the number of check outs by persons.
--
Thomas Clarke
Cyber Sea Incorporated
Barbados BB11070
web: http://cybersea.biz
[Non-text portions of this message have been removed]
> **Hi prwels,
>
>
> Try this replacing my query with
> yours.----------------------------------------------------------set term #
> ;execute blockRETURNS ( x varchar(20) )asdeclare i int = 102;beginwhile (i <
> 169) dobeginfor select a.EMP_NO from employee a where a.EMP_NO !=null into
> :xdo suspend;i = i +
> 1;endend#----------------------------------------------------------
> --jd
> --- On Fri, 6/17/11, prwels <prwels@...> wrote:
>
> From: prwels <prwels@...>
> Subject: [firebird-support] Looping Query to count checkouts
> To: firebird-support@yahoogroups.com
> Date: Friday, June 17, 2011, 9:58 AM
>
>
>
>
> Hi all,
>
> I have a database of assets which can be checked out by various people.
> There is a table of history, which records all the checking and checkout
> dates and times as well as personnel ids.
>
> So far I am able to use FlameRobin to count the checkouts for one
> individual at a time, but I would like to loop through all the personnel
> ids, so I only have to run the script once, rather than 60+ times.
>
> I finally got my initial loop code to work, but as soon as I add my SELECT
> line the code starts giving me "Token unknown" for the ';' at the end of the
> SELECT line. If I take out the semi-colon, it gives me the same error for
> the variable on the next line.
>
> Here is my code so far. Any suggestions would be appreciated.
>
> set term # ;
>
> execute block
>
> as
>
> declare i int = 102;
>
> begin
>
> while (i < 169) do
>
> begin
>
> select a."Description"
>
> from "AssetHistory" a
>
> where a."EntryType" = 'CheckOut' and a."Personnel_ID" = 103;
>
> i = i + 1;
>
> end
>
> end
>
> #
>
> [Non-text portions of this message have been removed]
>
>
>
How about:
select a."Personnel_ID", count(*) as check_out_cnt
from "AssetHistory" a
where
a."EntryType" = 'CheckOut'
group by a."Personnel_ID"
This will count the number of check outs by persons.
--
Thomas Clarke
Cyber Sea Incorporated
Barbados BB11070
web: http://cybersea.biz
[Non-text portions of this message have been removed]