Le jeudi 19 novembre 2009 à 01:20:24, Kris Kewley a écrit :
> Could you not create a function to do this instead?
>
> Set var_limit = 20% of row count
> Replace subquery with var_limit
>
Sure, see the previous mails from Pavel. You can also put the percent as a
parameter of the function.
--
Could you not create a function to do this instead?
Set var_limit = 20% of row count
Replace subquery with var_limit
Kris
On 18-Nov-09, at 14:27, Guillaume Lelarge
wrote:
Le mercredi 18 novembre 2009 à 20:24:09, Another Trad a écrit :
No, It doesn't.
In my machine:
First select
ERROR:
2009/11/18 Lee Hachadoorian :
> On Wed, Nov 18, 2009 at 2:30 PM, Pavel Stehule
> wrote:
>> yes, and don't use 20%.
>>
>> select * from foo order by somecol limit (select (count(*)*0.2)::int from
>> foo)
>>
>> Regards
>> Pavel
>
> Is this faster on a large table? Because (select (count(*)*20/100)
2009/11/18 Another Trad :
> But there is any way to do it?
CREATE OR REPLACE twenty()
RETURNS SETOF foo AS $$
DECLARE
rows int;
r record;
BEGIN
rows := (SELECT count(*) FROM foo);
FOR r IN EXECUTE 'SELECT * FROM r ORDER BY some col LIMIT ' || (rows
* 0.2)::int LOOP
RETURN NEXT r;
END
On Wed, Nov 18, 2009 at 2:30 PM, Pavel Stehule wrote:
> yes, and don't use 20%.
>
> select * from foo order by somecol limit (select (count(*)*0.2)::int from foo)
>
> Regards
> Pavel
Is this faster on a large table? Because (select (count(*)*20/100)) worked fine.
--
Sent via pgsql-sql mailing l
2009/11/18 Guillaume Lelarge :
> Le mercredi 18 novembre 2009 à 20:24:09, Another Trad a écrit :
>> No, It doesn't.
>> In my machine:
>>
>> First select
>> ERROR: syntax error at end of input
>> LINE 1: select * from rapadura.cliente limit 20%
>> ^
>
But there is any way to do it?
2009/11/18 Guillaume Lelarge
> Le mercredi 18 novembre 2009 à 20:24:09, Another Trad a écrit :
> > No, It doesn't.
> > In my machine:
> >
> > First select
> > ERROR: syntax error at end of input
> > LINE 1: select * from rapadura.cliente limit 20%
> >
Le mercredi 18 novembre 2009 à 20:24:09, Another Trad a écrit :
> No, It doesn't.
> In my machine:
>
> First select
> ERROR: syntax error at end of input
> LINE 1: select * from rapadura.cliente limit 20%
> ^
> Second one:
> ERROR: argument of LIMI
No, It doesn't.
In my machine:
First select
ERROR: syntax error at end of input
LINE 1: select * from rapadura.cliente limit 20%
^
Second one:
ERROR: argument of LIMIT must not contain subqueries
Postgres 8.3
2009/11/18 Lee Hachadoorian
> Your
Your SQL works for me exactly as it is (substituting a table in my
database). What error are you getting?
On Wed, Nov 18, 2009 at 2:12 PM, Another Trad wrote:
> My question is quite simple: I want to select all the records from my table,
> but I want apply a LIMIT of 20% in the lines. like:
> sel
My question is quite simple: I want to select all the records from my table,
but I want apply a LIMIT of 20% in the lines. like:
select * from client limit 20%
I have tried (of course, with no success) this:
select * from client limit ((select count(*) from client)*20/100)
ok, I did: SELECT count(DISTINCT c.cliente_id) as qtd_client,count(cm.cm_id)
as qtd_computers
GREAT. It works.
Please, explain me why and how it works, I wanna learn and do by myself next
time :)
2009/11/18 Oliveiros C,
> Try substituting the SELECT count(c) as qtd_client,count(cm) as
> qtd_co
Try substituting the SELECT count(c) as qtd_client,count(cm) as qtd_computers
by
SELECT count( DISTINCT c.cliente_id) as qtd_client,count(/* put here the
primary key of the computer table */ ) as qtd_computers
Then tell me if it output what you want
Best,
Oliveiros
- Original Message --
On Wed, Nov 18, 2009 at 9:55 AM, Another Trad wrote:
> The DB structure is in attachment.
> I with the number of clients and the number of computers that have
> processors with "manufacturer" = "INTEL" and "speed" = "2GB"
> I am trying:
>
> select count(c) as qtd_client, count(cm) as qtd_computers
The DB structure is in attachment.
I with the number of clients and the number of computers that have
processors with "manufacturer" = "INTEL" and "speed" = "2GB"
I am trying:
select count(c) as qtd_client, count(cm) as qtd_computers
from cliente c
inner JOIN computer cm on (c.cliente_id = cm.
Well, the username and password are the same, but the md5 is different. But
it doesn't seem to matter because either one works the same. The fact that
you can have 2 different md5's yet still have the same user name and
password and have logins work is what I found to be interesting.
But my origin
16 matches
Mail list logo