Created
June 10, 2010 20:45
-
-
Save MisterPhoton/433607 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
sp.invoiceId as 'InvId', | |
spMin.`date` as 'minDate', | |
spMax.`date` as 'maxDate' | |
FROM Guide_Invoice_ScheduledPayments sp | |
JOIN (SELECT invoiceId, MIN(`date`) as `date` from Guide_Invoice_ScheduledPayments group by invoiceId) as spMin on sp.invoiceId = spMin.invoiceId | |
JOIN (SELECT invoiceId, MAX(`date`) as `date` from Guide_Invoice_ScheduledPayments group by invoiceId) as spMax on sp.invoiceId = spMax.invoiceId | |
group by sp.invoiceId | |
having maxDate > minDate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment