Can you share your complete query?
It sounds like you are doing something like this:
SELECT
I.*,
SUM(final) OVER(PARTITION BY InvoiceNmbr) AS invoicedTotal
FROM
dbo.invoices AS I
WHERE
I.USER = 'jsmith';
But there are rows for an InvoiceNmbr by multiple users and when you run the query, you expect to see the total for the invoice number, while only showing details for the specific user. I think you need something like this:
SELECT
I.*,
TI.invoicedTotal
FROM
dbo.invoices AS I CROSS APPLY
(
SELECT SUM(final) AS invoicedTotal FROM dbo.invoices AS TI WHERE I.InvoiceNmber = I2.InvoiceNmbr
) AS TI
WHERE
I.USER = 'jsmith';
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question