From: | Pascual De Ruvo <deruvo(at)gmail(dot)com> |
---|---|
To: | ricky(at)connexiasolutions(dot)com |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Counting Row |
Date: | 2005-07-24 22:07:09 |
Message-ID: | fb73c1ee050724150758597439@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
I understand you need to count of tickets smaller than $recid given
[CONDITION], in that case:
$sql="select count(*) from [MYTABLE] where [CONDITION] and ticketnumber <="
.$recid ;
On 7/21/05, Ricky Sutanto <ricky(at)connexiasolutions(dot)com> wrote:
>
> Hi postgre people. Can anybody help to fix performance of my query?
>
> Let say, I have *n* number of queue ticket. (Which I use SELECT).
>
> Is there faster method to know where is my ticket number in queue?
>
> I use (while in PHP script ) and count one by one until my ticket number
> match with row field .
>
> $sql="select * from [MYTABLE] where [CONDITION] order by [FIELDORDER];
>
> $rs=&$ctclink->Execute($sql);
>
> $ctr=1;
>
> $pos=0;
>
> while (!$rs->EOF) {
>
> if ($rs->fields[0]==$recid) {
>
> $pos=$ctr;
>
> break;
>
> } else {
>
> $ctr++;
>
> $rs->MoveNext(); }
>
> }
>
> print $pos
>
> is there any method to do that with simple??
>
> *Thanks,*
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Mauricio Fernandez | 2005-07-25 07:59:05 | Re: Convert numeric to money |
Previous Message | Tom Lane | 2005-07-24 18:41:44 | Re: Different encodings in different DBs in same cluster |