Advertisement
dragonbs

People with Balance Higher Than

Oct 5th, 2023
1,879
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.37 KB | None | 0 0
  1. CREATE OR ALTER PROC usp_GetHoldersWithBalanceHigherThan(@balanceTreshold MONEY)
  2. AS
  3. BEGIN
  4.     SELECT [FirstName][First Name], [LastName][Last Name]
  5.     FROM [AccountHolders][ah]
  6.     LEFT JOIN [Accounts][a] ON [ah].[Id] = [a].[AccountHolderId]
  7.     GROUP BY [ah].[Id], [ah].[FirstName], [ah].[LastName]
  8.     HAVING SUM([a].[Balance]) > @balanceTreshold
  9.     ORDER BY [First Name], [Last Name]
  10. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement