Re: [SQL] lost password

2009-11-18 Thread Edward W. Rouse
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

[SQL] need nelp with aggregate functions

2009-11-18 Thread Another Trad
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 =

Re: [SQL] need nelp with aggregate functions

2009-11-18 Thread Scott Marlowe
On Wed, Nov 18, 2009 at 9:55 AM, Another Trad anothert...@gmail.com 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

Re: [SQL] need nelp with aggregate functions

2009-11-18 Thread Oliveiros C,
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

Re: [SQL] need nelp with aggregate functions

2009-11-18 Thread Another Trad
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, oliveiros.crist...@marktest.pt Try substituting the SELECT count(c) as

[SQL] LIMIT BASED ON PERCENT

2009-11-18 Thread Another Trad
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)

Re: [SQL] LIMIT BASED ON PERCENT

2009-11-18 Thread Lee Hachadoorian
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 anothert...@gmail.com 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

Re: [SQL] LIMIT BASED ON PERCENT

2009-11-18 Thread Another Trad
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

Re: [SQL] LIMIT BASED ON PERCENT

2009-11-18 Thread Another Trad
But there is any way to do it? 2009/11/18 Guillaume Lelarge guilla...@lelarge.info 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%

Re: [SQL] LIMIT BASED ON PERCENT

2009-11-18 Thread Pavel Stehule
2009/11/18 Guillaume Lelarge guilla...@lelarge.info: 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%                                            

Re: [SQL] LIMIT BASED ON PERCENT

2009-11-18 Thread Lee Hachadoorian
On Wed, Nov 18, 2009 at 2:30 PM, Pavel Stehule pavel.steh...@gmail.com 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

Re: [SQL] LIMIT BASED ON PERCENT

2009-11-18 Thread Pavel Stehule
2009/11/18 Another Trad anothert...@gmail.com: 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

Re: [SQL] LIMIT BASED ON PERCENT

2009-11-18 Thread Pavel Stehule
2009/11/18 Lee Hachadoorian lee.hachadoor...@gmail.com: On Wed, Nov 18, 2009 at 2:30 PM, Pavel Stehule pavel.steh...@gmail.com 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?

Re: [SQL] LIMIT BASED ON PERCENT

2009-11-18 Thread Kris Kewley
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 guilla...@lelarge.info wrote: Le mercredi 18 novembre 2009 à 20:24:09, Another Trad a écrit : No, It doesn't. In my

Re: [SQL] LIMIT BASED ON PERCENT

2009-11-18 Thread Guillaume Lelarge
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. --