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
> 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
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
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