Setting boolean column based on cumulative integer value

Поиск
Список
Период
Сортировка
От Markus Juenemann
Тема Setting boolean column based on cumulative integer value
Дата
Msg-id 9d8bdcf30612010550o3a5721lefc366e4984fd145@mail.gmail.com
обсуждение исходный текст
Ответы Re: Setting boolean column based on cumulative integer value  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Re: Setting boolean column based on cumulative integer value  (Richard Broersma Jr <rabroersma@yahoo.com>)
Re: Setting boolean column based on cumulative integer value  ("Aaron Bono" <postgresql@aranya.com>)
Список pgsql-sql
Hi (again!)

[stupid email program sent my message before I finished it!!!]

I've got a bit of a tricky (for me!) problem. The example below is
completely ficticious but
describes my real problem in a way which might be easier to understand.

Imagine the table contains a list of passenger wanting to get on a
small(!) plane.
The plane can carry at most 200kg of passengers and will be filled
strictly on a first-come
first-serve basis - well, check-in staff is a bit stupid ;-). So what
needs to be done is to set the 'gets_seat' column to true until the
weight limit is reached.

CREATE TABLE passenger_queue (
id serial NOT NULL,
name character varying(40) NOT NULL,
weight integer NOT NULL,
gets_seat boolean default false
)

insert into passenger_queue values (1,"Peter",75,false)
insert into passenger_queue values (2,"Mary",50,false)
insert into passenger_queue values (3,"John",70,false)
insert into passenger_queue values (4,"Steve",80,false)

According to the specifications given above Peter, Mary and John would
have 'gets_seat'
set to true because their cumulative weight is 195kg while Steve misses out.

The big question is: How can I do this in a nice SQL query???

Thanks

Markus


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Markus Juenemann"
Дата:
Сообщение: Set binary column dependent on cumulative value of integer column
Следующее
От: "Ezequias Rodrigues da Rocha"
Дата:
Сообщение: Re: Grants