Skip to content

Instantly share code, notes, and snippets.

@puzanov
Created May 11, 2017 05:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save puzanov/b38e5904dbf08ea7f9b2a345609ba481 to your computer and use it in GitHub Desktop.
Save puzanov/b38e5904dbf08ea7f9b2a345609ba481 to your computer and use it in GitHub Desktop.
select
m.source_host,
m.external_link,
m.count,
m.external_host,
m.created,
coalesce(t1.hosttype,'N') as 'source_host_type',
coalesce(t2.hosttype,'N') as 'external_host_type'
from monitor as m
LEFT OUTER JOIN types as t1 ON t1.hostname=m.source_host
LEFT OUTER JOIN types as t2 ON t2.hostname=m.external_host
where
m.external_host not in (select distinct external_host from monitor where created < '2017-01-12')
and m.created between '2017-01-12 00:00:00' and '2017-01-12 23:59:59';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment