Re: Query challenge
Date: 1995/05/02
Message-ID: <D7y34q.9LA_at_fih.dk>#1/1
In article <qili.799355663_at_copper>, qili_at_indiana.edu (Kenneth Li) says:
>
>Hi, there,,
>
>I have a table (call it Table 1) with the following structure:
>
> Fields: ID Month DelCat
>
>where ID is customer identification number, DelCat is the customer's
>delinquency status with values of 10, 15, 20 or 50 in month specified by Month.
>
>I would like to generate Table 2 like
>
> Fields: ID Ct10Mth Ct15Mth Ct20Mth Ct50Mth
>
>where ID is the customer id in Table 1, Ct10Mth is the *FIRST* month
>that customer was in DelCat 10; Ct15Mth is the *FIRST* month that customer
>was in DelCat 15, etc.
>
>I have not been able to find a query to generate such a table.
>
>Your help is appreciated.
>==========================================================================
> Enjoy Life! | Internet: qili_at_indiana.edu
> --- Kenneth Li | Bitnet: qili_at_indiana.bitnet
>
>
>--
>==========================================================================
> Enjoy Life! | Internet: qili_at_indiana.edu
> --- Kenneth Li | Bitnet: qili_at_indiana.bitnet
Try this
CREATE TABLE TABLE2 (ID, CT10MTH, CT15MTH, CT20MTH, CT50MTH) AS SELECT ID,
MIN(DECODE(DELCAT,'10',MONTH,NULL)), MIN(DECODE(DELCAT,'15',MONTH,NULL)), MIN(DECODE(DELCAT,'20',MONTH,NULL)), MIN(DECODE(DELCAT,'50',MONTH,NULL))
FROM TABLE1
GROUP BY ID Best Regards
SBC
sbc_at_fih.dk Received on Tue May 02 1995 - 00:00:00 CEST