Re: Displaying the count

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In message <fkpm0e+dadj@xxxxxxxxxxx>, Ken <ken.poyser@xxxxxxxxxxx>
writes
>I have a SQL  that lists the agencies that have records entered.
>
>My SQL is
>
>$sql = "SELECT ORI, Agy_Name, Tele_Num from $table_name group by ORI 
>having count(ORI) > 0";
>
>
>I am wanting to show the "count" as well.
>
>
>I have looked around  but I haven't seen anything on how to
>display the count!

Are you sure that the SQL is doing what you want it to do??

A quick look at it, without understanding the significance of the ORI
field, tells me that the command says "Show me the first Agency Name and
Telephone number from each set of agencies having the same ORI".

If that's what you want (what about the second and subsequent agencies?)
then the answer is simply to add SELECT ORI, count( ORI ), ....

which will say, "show me the ORI, and how many ORIs there are with the
same code, and the name and phone number of the first agency with that
ORI"

Is that what you want?

-- 
Pete Clark

Sunny Andalucia
http://hotcosta.com/Andalucia.Spain

[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux