MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 18th, 2013, 05:42 AM
Ibzy Ibzy is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 1 Ibzy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 37 m 54 sec
Reputation Power: 0
Sum previous Invoices base on Invoice ID

Hi All,

Not too great a title, but a little hard to describe in few words.
I have an invoicing system and need to be able to tot up the value of each accounts' invoices prior to the addition of the invoice in question. For example: John has 3 invoices for £100 each and has just received another invoice this week for £100. I need to be able to report based on a date period the value of the account prior to this new invoice (as laid out below).

ID Name InvID InvTotal PreviousValue NewValue
001 John 004 100 300 400

I'm able to get this fine if only one invoice is raised within in the data range, however if 2 or more are raised it will only give the previous value for the latest invoice against all invoices (again, sample below).

ID Name InvID InvTotal PreviousValue NewValue
001 John 004 100 500 600
001 John 005 100 500 600
001 John 006 100 500 600

When what I need is:

ID Name InvID InvTotal PreviousValue NewValue
001 John 004 100 300 400
001 John 005 100 400 500
001 John 006 100 500 600

The query can be parsed using only one table(view) which is a combination of CLIENT and INVOICE (CLIENT_INVOICE - original! )

Any idea how I might accomplish this? I can post my current code if it will help?

Thanks

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Sum previous Invoices base on Invoice ID

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap