Skip to content

Instantly share code, notes, and snippets.

@dstreefkerk
Created July 9, 2015 00:38
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 dstreefkerk/0b2e9329b845f31bd7e1 to your computer and use it in GitHub Desktop.
Save dstreefkerk/0b2e9329b845f31bd7e1 to your computer and use it in GitHub Desktop.
SQLite query to extract users from Spiceworks' DB for tickets created in the past 2 years and get it into the format required by FreshDesk for contact import via CSV
select distinct u.email as email,
u.first_name || ' ' || u.last_name as name,
u.title as job_title,
u.cell_phone as mobile,
u.office_phone as phone,
u.location as time_zone,
'en' as language
from users as u
inner join tickets as t on u.id = t.created_by
where (u.disabled is null) and ((u.first_name is not null) and (u.last_name is not null))
and (t.created_at > date('now','-2 years'))
order by u.last_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment