From: | Thomas Drebert <drebert(at)web(dot)de> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | joining 2 Tables. |
Date: | 2014-03-17 10:14:41 |
Message-ID: | CANn+32jMhoTirqkjjkdQKaTwcnGLSzwnkB+qYbaunW9hPNWzbg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | David Johnston | 2014-03-17 13:52:07 | Re: joining 2 Tables. |
Previous Message | Daryl Foster | 2014-03-14 16:58:55 | Re: Cannot insert to 'path' field using EclipseLink |