Skip to content

Instantly share code, notes, and snippets.

@wmakeev
Created September 28, 2020 05:23
Show Gist options
  • Save wmakeev/c4a9751dea436eb8c7062d6bb36a7991 to your computer and use it in GitHub Desktop.
Save wmakeev/c4a9751dea436eb8c7062d6bb36a7991 to your computer and use it in GitHub Desktop.
[SQL tips] #sql #tips
SELECT TOP 100
ActiveDocumentPosition.metaType,
SUM(
CASE
WHEN ActiveDocumentPosition.metaType = 'demandposition'
THEN ActiveDocumentPosition.price
ELSE -ActiveDocumentPosition.price
END
) AS value
FROM ActiveDocumentPosition
GROUP BY ActiveDocumentPosition.metaType;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment