joining 2 Tables. - Mailing list pgsql-novice

From Thomas Drebert
Subject joining 2 Tables.
Date
Msg-id CANn+32jMhoTirqkjjkdQKaTwcnGLSzwnkB+qYbaunW9hPNWzbg@mail.gmail.com
Whole thread Raw
Responses Re: joining 2 Tables.  (David Johnston <polobo@yahoo.com>)
List pgsql-novice
Hallo,

trying to join these two tables.

SELECT to_timestamp(trunc(date_part('epoch', updatezeit)/600) * 600) at time zone 'mez' AS updatezeit,
       count(*) as thecount,
       round (cast(avg (value)as numeric),1) as avg,
       round (cast(min (value)as numeric),1) as min,
       round (cast(max (value)as numeric),1) as max
FROM variablen WHERE updatezeit >= '12.03.2014 00:00:00' AND varid = '35177'
GROUP BY to_timestamp(trunc(date_part('epoch', updatezeit)/600) * 600) at time zone 'mez'
ORDER BY updatezeit

and 

SELECT foo.updatezeit
FROM (select ('12.03.2014 00:00:00'::timestamp + s * '10minutes'::interval) AS updatezeit 
FROM generate_Series(0,4000)s) as foo

by using this code

SELECT 
foo.updatezeit
FROM (select ('12.03.2014 00:00:00'::timestamp + s * '10minutes'::interval) AS updatezeit 
FROM generate_Series(0,4000)s) as foo
left join
(
SELECT to_timestamp(trunc(date_part('epoch', updatezeit)/600) * 600) at time zone 'mez' AS updatezeit,
       count(*) as thecount,
       round (cast(avg (value)as numeric),1) as avg,
       round (cast(min (value)as numeric),1) as min,
       round (cast(max (value)as numeric),1) as max
FROM variablen WHERE updatezeit >= '12.03.2014 00:00:00' AND varid = '35177'
GROUP BY to_timestamp(trunc(date_part('epoch', updatezeit)/600) * 600) at time zone 'mez'
ORDER BY updatezeit
) as n2
using(updatezeit)
group by 1
order by 1

but the result is only the left table.

regarts
Thomas

pgsql-novice by date:

Previous
From: Adam Mackler
Date:
Subject: Re: Relational loops in a DB
Next
From: David Johnston
Date:
Subject: Re: joining 2 Tables.