contoh date_trunc postgresql

SELECT hasilping.hostname, hasilping.ip_source, hasilping.ip_destination, date_trunc('hour'::text, hasilping.college_time) AS collect_time, sum(hasilping.count) AS packet, avg(hasilping.rtt_delay) AS rtt_delay, min(hasilping.rtt_min) AS rtt_min, max(hasilping.rtt_max) AS rtt_max, avg(hasilping.packet_loss) AS packet_loss, avg(hasilping.availability) AS availability, avg(hasilping.jitter) AS jitter
  FROM hasilping
 WHERE date_trunc('day'::text, hasilping.college_time) = date_trunc('day'::text, now() - '1 day'::interval)
 GROUP BY hasilping.hostname, hasilping.ip_source, hasilping.ip_destination, date_trunc('hour'::text, hasilping.college_time)
 ORDER BY date_trunc('hour'::text, hasilping.college_time);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s