Skip to content

Instantly share code, notes, and snippets.

@ddieppa
Last active March 21, 2016 18:03
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 ddieppa/f9570ce7441e38acc6ca to your computer and use it in GitHub Desktop.
Save ddieppa/f9570ce7441e38acc6ca to your computer and use it in GitHub Desktop.
Useful SQL queries

SQL queries

Some of the sql queries I used at some point :)

Files in this gist

SELECT TOP 1 EmailType.EmailAddress
FROM (
SELECT TOP 1 *
FROM ContactEmail ce
WHERE ce.EmailTypeId = 5 AND ce.ContactBaseId = @contactId
UNION
SELECT TOP 1 *
FROM ContactEmail agce
WHERE agce.EmailTypeId = 1 AND agce.ContactBaseId = @contactId
) AS EmailType
/***************************************************************************************
** Auth:
** Date:
** Desc:
** File:
** Name:
**************************
** Unit Tests
**************************
**************************
** Change History
**************************
** PR Date Author Description
** -- -------- --------------------- ------------------------------------
** 1 01/10/2008 Dan added inner join
*****************************************************************************************/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment