Skip to content

Instantly share code, notes, and snippets.

@robherley
Created May 6, 2019 18:37
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 robherley/a18f10dc0b4bf977c6f812bf5d341bf2 to your computer and use it in GitHub Desktop.
Save robherley/a18f10dc0b4bf977c6f812bf5d341bf2 to your computer and use it in GitHub Desktop.
const SQL = require('sql-template-strings');
module.exports = {
slice: (start, end) => SQL`
SELECT
eventid,
CAST(latitude AS REAL) AS latitude,
CAST(longitude AS REAL) AS longitude,
CAST(nkill AS INT) AS nkill,
CAST(iyear AS INT) AS year
FROM
attacks
WHERE
iyear >= ${+start} AND iyear <= ${+end}
`,
infoById: id => SQL`
SELECT * FROM attacks WHERE eventid = ${id}
`
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment