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 |
|
sree432
Starting Member
7 Posts |
Posted - 2004-11-26 : 06:34:03
|
| Input Table ‘T1’ Contains Following DataCNAME PARTTYPE PARTID JDATE QTYLUCENT TELECOM TB1 01/12/70 1000TEXAS TELECOM TB2 05/02/75 2000TEXAS AUTO AM1 10/25/85 1000LUCENT AUTO AM2 07/18/92 1500TEXAS AUTO AM3 01/17/93 3500LUCENT TELECOM TB3 09/28/97 2500Output Data Should Be Like FollowingCNAME PARTTYPE PARTID JDATE QTY CID PID WEEKSLUCENT TELECOM TB1 01/12/70 1000 C2 P2.3 135TEXAS TELECOM TB2 05/02/75 2000 C1 P2.2 34TEXAS AUTO AM1 10/25/85 1000 C1 P1.3 16LUCENT AUTO AM2 07/18/92 1500 C2 P1.2 67TEXAS AUTO AM3 01/17/93 3500 C1 P1.1 13LUCENT TELECOM TB3 09/28/97 2500 C2 P2.1 25For CID Is an incremental field with ‘C’ as prefix It is derived based on ‘Qty’ field So, C1 is given to a Company (based on CNAME) where it got max Qty Like that C2 for next highest Company etc.,For PID Is got ‘Pa.b’ format, Where ‘P’ Prefix How to get a : Based on ‘PARTTYPE’ a = 1, when it has got max qty How to get b : Based on ‘PARTID’ b = 1, when it has got max qty with in ‘PARTTYPE’For WEEKS How many weeks from ‘JDATE’ to Current DateAny Method you can Use to Get Output, But It Should Be In an Optimal way.Thanks in advanceRegardsSreedhar Reddy |
|
|
|
|
|