Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Microsoft SQL Server > HELP WITH SELEC...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 10976 of 11205
Post > Topic >>

HELP WITH SELECT STATEMENT PLEASE

by markgordon_007@[EMAIL PROTECTED] Apr 17, 2008 at 06:09 AM

Hello Group

I having problems creating a result set. The challenge is I have 3
tables: A customer table, A charge table and a payment table..... The
result set needs to show all payments and what detail lines were paid
down by each payment. Both the detail line table and payment table can
contain positive and negative transactions...... Each payment must be
listed and split across the detail lines if needed... unpaid detail
lines should not be displayed in the final result set..,.. If a
customer paid more money then he owes that needs to display in the
result set as well....

Any assistance anyone could provide will be greatly appreciated

Customer: customer name, customer id, customer pk
charge: transaction date, quantity, item id, item description, unit
price, total price customer id
Payment Table: transaction date, payment type, payment amount,
description (optional) customer id

customer data
customer 1 QWER  COMPANY
customer 2  ZXCV   COMPANY
customer 2  IOP     COMPANY

charge data
customer 1, 04/01/2008, 3 WIDGET A,   5.00,  15,00
customer 1 04/02/2008,  1 WIDGET B    2,00,    2.00
customer 1 04/03/2008   3 WIDGET A   -5.00, -15.00

customer 2 04/10/2008   1 WIDGET A    5.00     5.00
customer 2 04/12/2008   2 WIDGET D  10.00    20.00
customer 2 04/15/2008   5 WIDGET C  20.00  100.00
customer 2 04/20/2008   2 WIDGET X 100.00  200.00

payment data
customer 1, 04/05/2008  CASH        2.00

customer 2  05/01/2008  CHECK   100.00
customer 2  05/10/2008  CHECK  - 100.00 (RETURN CHECK)
customer 2  05/20/2008  CASH        15.00
customer 2  05/25/2008  VISA       500.00

RESULT SET

CUSTOMER 1 04/05/2008 CASH      2.00
04/02/2008 WIDGET B 2.00

CUSTOMER 2 05/01/2008 CHECK  100.00
CUSTOMER 2 05/10/2008 CHECK -100.00 RETURN CHECK
CUSTOMER 2 05/20/2008 CASH       5.00
04/10/2008 WIDGET A 5.00
CUSTOMER 2 05/20/2008 CASH     10.00
04/12/2008 WIDGET D 10.00
CUSTOMER 2 05/20/2008 VISA 10.00
04/12/2008 WIDGET D 10.00
CUSTOMER 2 05/20/2008 VISA 100.00
04/15/2008 WIDGET C 100.00
CUSTOMER 2 05/20/2008 VISA 200.00
04/12/2008 WIDGET D 200.00
CUSTOMER 2 05/20/2008 VISA 290.00

ETC ......
 




 3 Posts in Topic:
HELP WITH SELECT STATEMENT PLEASE
markgordon_007@[EMAIL PRO  2008-04-17 06:09:33 
Re: HELP WITH SELECT STATEMENT PLEASE
--CELKO-- <jcelko212@[  2008-04-17 09:29:57 
Re: HELP WITH SELECT STATEMENT PLEASE
Ed Murphy <emurphy42@[  2008-04-18 07:08:47 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Sun Jul 6 4:40:57 CDT 2008.