I have looked far and wide for a way to get rows of results into columns to no avail. I have order numbers that have multiple payments and I need the balance left unpaid. My anger comes from MSSQL2000 w/o pivot
Here's an example:
Column names:
[ip_amt | packout_id | payments_id | date_received | invoice_num | amount_received]
[html]
114.1300 22859 105 2007-02-05 INV123 94.27
NULL 22859 2628 2007-03-05 INV123 19.86[/HTML]
$114.13 is what I paid, and $94.27 + $19.86 is what I was paid over two months.
I need the balance amount but in the first column, I've only got the balance of one month and the next month doesn't have enough data. How can I sum up the two amount_received cells on the far-right column?
What I need is for it to say "Balance = $0.00 for this invoice" since over the two months, it equals the $114.13
This is the view that I am querying to get the columns
Any suggestions?
Here's an example:
Column names:
[ip_amt | packout_id | payments_id | date_received | invoice_num | amount_received]
[html]
114.1300 22859 105 2007-02-05 INV123 94.27
NULL 22859 2628 2007-03-05 INV123 19.86[/HTML]
$114.13 is what I paid, and $94.27 + $19.86 is what I was paid over two months.
I need the balance amount but in the first column, I've only got the balance of one month and the next month doesn't have enough data. How can I sum up the two amount_received cells on the far-right column?
What I need is for it to say "Balance = $0.00 for this invoice" since over the two months, it equals the $114.13
This is the view that I am querying to get the columns
Code:
select sum(user_item_credit_amount) as ip_amt, amount_received, p.amount_received - sum(user_item_credit_amount) bal, --p.date_received, p.check_credit_num, p.packout_id, pk.invoice_num, date_received, p.payments_id from payments p, item_payments i, packout pk where i.payments_id = p.payments_id and pk.packout_id = i.packout_id group by date_received,pk.invoice_num,amount_received,check_credit_num,p.packout_id, p.payments_id
Any suggestions?
Comment