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 > Re: HELP WITH S...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 3 Topic 10976 of 11516
Post > Topic >>

Re: HELP WITH SELECT STATEMENT PLEASE

by Ed Murphy <emurphy42@[EMAIL PROTECTED] > Apr 18, 2008 at 07:08 AM

--CELKO-- wrote:

> Please post DDL, so that people do not have to guess what the keys,
> constraints, Declarative Referential Integrity, data types, etc. in
> your schema are. If you know how, follow ISO-11179 data element naming
> conventions and formatting rules, so that people can read your posting
> and understand it (i.e names like Table_A is pretty useless).  Sample
> data is also a good idea, along with clear specifications.  It is very
> hard to debug code when you do not let us see it.  If you want to
> learn how to ask a question on a Newsgroup, look at:
> http://www.catb.org/~esr/faqs/smart-questions.html
<<

While the customer table is indeed a couple types of unclear, it doesn't
appear to be directly relevant.  From context, the specifications are as
follows:

  1) Negative charges are applied to positive charges for the same
     customer and item (earliest first on both sides), canceling
     them out in whole or part.

  2) Negative payments are applied to positive payments for the same
     customer (earliest first on both sides), canceling them out in
     whole or part.

  3) Uncanceled payments are applied to uncanceled charges for the same
     customer (earliest first on both sides) and displayed in
     interleaved order, including unapplied payment amounts (if any).

Personally, I would do most of the work at the re****ting layer, but I
suppose you could get some mileage out of something like the following:

create view customer_activity as
	select	customer_id,
		transaction_date,
		item_id,
		total_price as amount,
		'Charge' as transaction_type
	from	customer_charges
union
	select	customer_id,
		transaction_date,
		null as item_id,
		payment_amount as amount,
		'Payment' as payment_type
	from	customer_payments
 




 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
tan12V112 Mon Dec 1 23:14:56 CST 2008.