e -From: "Sergio Duran" <[EMAIL PROTECTED]>To: <pgsql-general@postgresql.org
>Sent: Thursday, July 13, 2006 9:20 PMSubject: [GENERAL] I need help creating a query> Hello,>> I need a little help creating a query, I have two tables, worker and> position, for simplicity
- Original Message -
From: "Sergio Duran" <[EMAIL PROTECTED]>
To:
Sent: Thursday, July 13, 2006 9:20 PM
Subject: [GENERAL] I need help creating a query
> Hello,
>
> I need a little help creating a query, I have two tables, worker and
> position, for simplic
This is what I did, I used plpgsql,create or replace function first_accum(anyelement, anyelement) returns anyelement as $$BEGIN IF $1 IS NOT NULL THEN return $1; ELSE return $2; END IF; END' language plpgsql;
then I created the aggregateCREATE AGGREGATE first(sfunc = first_accum, basetype = a
> create table worker(
> name varchar(50),
> position varchar(50),
> startdate date,
> salary numeric(9,2));
> insert into worker values ('Jon', 'boss', '2001-01-1', 1000.00);
> insert into worker values ('Peter', 'cleaning', '2002-01-01', 100.00);
> insert into worker values ('Pet
On 15/07/2006, at 2:07 AM, Sergio Duran wrote:How about if we make it simpler, only 1 tablecreate table worker( name varchar(50), position varchar(50), startdate date, salary numeric(9,2));insert into worker values ('Jon', 'boss', '2001-01-1', 1000.00);insert into worker values ('Peter'
How about if we make it simpler, only 1 tablecreate table worker( name varchar(50), position varchar(50), startdate date, salary numeric(9,2));insert into worker values ('Jon', 'boss', '2001-01-1',
1000.00);insert into worker values ('Peter', 'cleaning', '2002-01-01', 100.00);insert in
Nice, Richard, but you use max(startdate), how about the salary? i cant use max(salary) how about if he got a pay cut?My current solution is to write the nested query on the field list, like SELECT worker.*,
(select salary FROM position where worker_id=worker.worker_id and fecha<='2006
>
> worker: worker_id, name
> position: position_id, worker_id, position, startdate, salary
>
> If I perfom a query joining both tables, I can obtain all the workers and
> the positions the've had.
>
> SELECT name, startdate, position, salary FROM worker JOIN position
> USING(worker_id);
> wo
] I need help
creating a query
Hello,
I need a little help creating a query, I have two tables, worker and position,
for simplicity sake worker only has its ID and its name, position has the ID of
the worker, the name of his position, a date, and his salary/
worker: worker_id, name
Hello,I need a little help creating a query, I have two tables, worker and position, for simplicity sake worker only has its ID and its name, position has the ID of the worker, the name of his position, a date, and his salary/
worker: worker_id, nameposition: position_id, worker_id, position, sta
10 matches
Mail list logo