Skip to content

Instantly share code, notes, and snippets.

@bcambel
Created November 22, 2015 19:07
Show Gist options
  • Select an option

  • Save bcambel/a2c19be44ae011c4ae2c to your computer and use it in GitHub Desktop.

Select an option

Save bcambel/a2c19be44ae011c4ae2c to your computer and use it in GitHub Desktop.
CREATE FUNCTION day_view_generator (day character varying) RETURNS void
VOLATILE
AS $$
BEGIN
EXECUTE format('CREATE TABLE IF NOT EXISTS events_' || day || ' AS (SELECT 1 as pv, evt_name, hour, device_type, browser, os, domain, path, utm_source, utm_medium, utm_campaign, utm_content, utm_term, country FROM events limit 1)');
END;
$$ LANGUAGE plpgsql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment