Unfortunately, I've let my l33t LLBLGen skills wane
and I can't quite figure out how to translate this into LLBLGen-eese. Can anyone help me out?
Thanks,
Chris
INSERT INTO [NotificationQueue]
(
[NotificationId],
[ArticleId],
[Created]
)
SELECT
ArticleNotification.NotificationId,
ArticlePendingNotificationProcess.ArticleId,
GETDATE()
FROM
ArticlePendingNotificationProcess
INNER JOIN
ArticleNotification ON ArticlePendingNotificationProcess.ArticleId = ArticleNotification.ArticleId
INNER JOIN
Notification ON ArticleNotification.NotificationId = Notification.NotificationId
INNER JOIN
NotificationCredit ON Notification.UserId = NotificationCredit.UserId
LEFT OUTER JOIN
NotificationUsage ON Notification.NotificationId = NotificationUsage.NotificationId
AND
NotificationCredit.NotificationCreditId = NotificationUsage.NotificationCreditId
WHERE (NotificationCredit.CreditCount > 0)
GROUP BY
ArticleNotification.NotificationId,
ArticlePendingNotificationProcess.ArticleId,
Notification.UserId,
NotificationCredit.CreditCount
HAVING
(SUM(ISNULL(NotificationUsage.CreditsUsed, 0)) < NotificationCredit.CreditCount)