Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
rpc86
Posting Yak Master
200 Posts |
Posted - 2006-02-14 : 22:52:51
|
hi guys, thanks for the recent help you advised to me.Now my next problem is how to distict BuyerCodes with different amount.here is my tableTable Name: PaymentScheduleBuyercode DueDate Amount ---------- --------------------------- -------------------- E24-5336 2005-10-06 00:00:00.000 115849.61E24-5336 2005-11-06 00:00:00.000 117297.73E24-5336 2005-12-06 00:00:00.000 118763.95E24-5336 2006-01-06 00:00:00.000 120248.50E24-5336 2006-02-06 00:00:00.000 121751.60E24-5337 2001-03-04 00:00:00.000 53851.99E24-5337 2001-04-04 00:00:00.000 53851.99E24-5337 2001-05-04 00:00:00.000 53851.99E24-5337 2001-06-04 00:00:00.000 53851.99E24-5337 2001-07-04 00:00:00.000 53851.99E24-5350 2001-04-07 00:00:00.000 63162.44E24-5350 2001-05-07 00:00:00.000 63162.44E24-5350 2001-06-07 00:00:00.000 63162.44N10-5023 2005-11-30 00:00:00.000 21946.53N10-5023 2005-12-30 00:00:00.000 22129.42N10-5023 2006-01-30 00:00:00.000 22313.83N10-5023 2006-02-28 00:00:00.000 22499.78N10-5023 2006-03-30 00:00:00.000 22687.28 The result I need is the following:BuyerCode---------E24-5336 N10-5023 Because these 2 BuyerCode have different amount for every duedates.Many thanks. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-02-14 : 23:00:54
|
| [code]select Buyercodefrom PaymentSchedulegroup by Buyercodehaving count(*) > 1[/code]----------------------------------'KH'everything that has a beginning has an end |
 |
|
|
rpc86
Posting Yak Master
200 Posts |
Posted - 2006-02-14 : 23:02:56
|
| But it will include these 2 buyercodesE24-5337 E24-5350 These 2 code has the same amount for each duedate unlike the desired result. |
 |
|
|
shallu1_gupta
Constraint Violating Yak Guru
394 Posts |
Posted - 2006-02-14 : 23:09:49
|
| Hi,Try this..select Buyercodefrom (select distinct buyercode, amount from PaymentSchedule )agroup by Buyercodehaving count(*) > 1 |
 |
|
|
rpc86
Posting Yak Master
200 Posts |
Posted - 2006-02-14 : 23:13:39
|
| shallu1 gupta, thanksThe code is nearly close to my result but, there must have a condition for the duedates that are consecutively different by amount. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-02-14 : 23:23:50
|
quote: different amount for every duedates.
Does this means all the amount must be different ?select Buyercodefrom PaymentSchedule pgroup by Buyercodehaving count(distinct Amount) = (select count(*) from PaymentSchedule x where x.Buyercode = p.Buyercode) ----------------------------------'KH'everything that has a beginning has an end |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-02-15 : 00:35:08
|
Other method isSelect buyercode from( select distinct buyercode,amount from PaymentSchedule ) Tgroup by buyercode having count(buyercode)<>1 MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|