Re: [GENERAL] how to remove a for-loop from programming language and put it into the query?

2010-07-05 Thread Pedro Zorzenon Neto
Em 05-07-2010 12:22, Sam Mason escreveu: > > You want to be using DISTINCT ON or some sort of WINDOW function. > DISTINCT ON works with older version of PG, but isn't as standards' > conforming. The following should do the trick with DISTINCT ON: > > SELECT DISTINCT ON (hardware_id) hardware_i

Re: [GENERAL] how to remove a for-loop from programming language and put it into the query?

2010-07-05 Thread Pedro Zorzenon Neto
> I'm probably misunderstanding the problem, but can't you just do: > > SELECT > diag_value > FROM > diagnose_logs > WHERE > ts <= '2009-12-25 23:59:59' > AND > hardware_id BETWEEN 1 AND 500 > ORDER BY > ts DESC > LIMIT 1 Hi Thom, Yes, I think you misunderstood. An

[GENERAL] how to remove a for-loop from programming language and put it into the query?

2010-07-05 Thread Pedro Zorzenon Neto
Hello! Can someone help me to develop a query? Things are more complex than this example, but with this simple example I can explain what I need and get an answer. Table: "diagnose_logs" Fields: - id serial - hardware_id integer - diag_value integer - ts timestamp So I collect many diag

[GENERAL] Grant on table without access to other tables structure

2010-02-03 Thread Pedro Zorzenon Neto
Hi, I will explain what I need with a simple example. I have three tables: jobs, people, cities I have to grant select on people to john. GRANT SELECT ON PEOPLE TO JOHN; Now, when john opens "psql", it can do the selects. That is OK. But when john does \d \d cities