79497966

Date: 2025-03-10 12:20:04
Score: 1.5
Natty:
Report link

I've just seen this many years later and to me it doesn't make sense and should be simple. Those IDs are just a surrogate key in let's say dbo.transactions.

The system absolutely <HAS> to have a way those amounts and IDs belong to certain clients otherwise how can you determine who made them? The amounts <MUST> belong to different people because sequential IDs can only be for surrogate [internal] use.

Therefore you must be able to join back, and find the client for each amount.

Therefore you join to the table that shows the client, SELECT INTO #WorkTable, and once you have the clients it's a simple SUM(), GROUP BY.

If those IDs are not unique, then they already represent a client and the same thing applies.

My gut feeling is there should always be a GROUP BY possible here? Otherwise you couldn't know which client the amounts belong to?

You have to know what client the amounts belong to - hence you can group them in a temp table.

My £0.2 pence. Peace

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: GMan_LDN