Pavel Stehule wrote:
>> SELECT
>> appointments.name AS appointment,
>> (SELECT COUNT(*) FROM employees AS e where e.appointment_id =
>> appointments.id) AS num_employees,
>> (SELECT array_to_string(array_accum(name),', ') FROM employees AS e
>> WHERE e.appointment_id = appointments.id) AS employe
On 21/12/2007, Philippe Lang <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > Philippe Lang <[EMAIL PROTECTED]> schrieb:
> >
> > 2 ways:
> >
> > * You can use something like this:
> >
> > test=*# select * from a;
> > id | val
> > +-
> > 1 | foo
> > 2 | bar
> > (2 rows)
> >
> >
[EMAIL PROTECTED] wrote:
> Philippe Lang <[EMAIL PROTECTED]> schrieb:
>
> 2 ways:
>
> * You can use something like this:
>
> test=*# select * from a;
> id | val
> +-
> 1 | foo
> 2 | bar
> (2 rows)
>
> test=*# select array_to_string(array(select val from a), ', ');
> array_to_strin
On Friday 21. December 2007, Niklas Johansson wrote:
>select array_to_string(array[given, patronym, toponym], ' ') from
>persons where person_id=57;
>
>Notice the use of the array[] constructor, instead of the array()
>constructor, which must be fed a subquery which returns only one
> column.
Aah
On 21 dec 2007, at 12.16, Leif B. Kristensen wrote:
I've got a similar problem. My persons table has a number of fields
for
different name parts: given, patronym, toponym, surname, occupation,
epithet.
I'd like something more elegant, like the
Python or PHP join() function. I tried Andreas'
On Dec 21, 2007 4:16 PM, Leif B. Kristensen <[EMAIL PROTECTED]> wrote:
> On Friday 21. December 2007, Philippe Lang wrote:
>
> >(SELECT CONCAT(name, ', ') FROM employees AS e where e.appointment_id
> > = appointments.id) AS employees
> >FROM appointments
> >--
> >
> >...
On Friday 21. December 2007, Philippe Lang wrote:
>(SELECT CONCAT(name, ', ') FROM employees AS e where e.appointment_id
> = appointments.id) AS employees
>FROM appointments
>--
>
>... where CONCAT suggest we want to concatenate the variable inside,
>with the separator
Hello
postgres=# select name, count, employes from (select appointment_id,
count(*), (SELECT array_to_string(ARRAY(SELECT name from employees
where appointment_id = e.appointment_id),',')) as employes from
employees e group by appointment_id)s join appointments a on a.id =
s.appointment_id;
name
Philippe Lang <[EMAIL PROTECTED]> schrieb:
2 ways:
* You can use something like this:
test=*# select * from a;
id | val
+-
1 | foo
2 | bar
(2 rows)
test=*# select array_to_string(array(select val from a), ', ');
array_to_string
-
foo, bar
(1 row)
* comma-aggrega
Hi,
Here is small reduced test database:
--
CREATE TABLE appointments
(
id integer,
name varchar(32),
CONSTRAINT appointments_pkey PRIMARY KEY (id)
);
CREATE TABLE employees
(
id integer,
appointment_id integer,
name varchar(32),
CONSTRAINT employees_pke
10 matches
Mail list logo