joining 2 Tables.
От | Thomas Drebert |
---|---|
Тема | joining 2 Tables. |
Дата | |
Msg-id | CANn+32jMhoTirqkjjkdQKaTwcnGLSzwnkB+qYbaunW9hPNWzbg@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: joining 2 Tables.
|
Список | 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 по дате отправления: