himanshupant
New User
Joined: 21 Mar 2007 Posts: 46 Location: India
|
|
|
|
Hi
Below is the DCLGEN of a table :-
Code: |
PAR SMALLINT NOT NULL,
BR INTEGER NOT NULL,
ACC INTEGER NOT NULL,
RUN_DATE DATE NOT NULL,
A_U_IND CHAR(1) NOT NULL,
DRATE CHAR(4) NOT NULL,
START_DA DATE NOT NULL,
ITYPE CHAR(1) NOT NULL,
BLIMIT DECIMAL(13, 2) NOT NULL,
THOLD DECIMAL(15, 0) NOT NULL,
AIT DECIMAL(15, 0) NOT NULL |
In the above table the keys are the column 1 - 6 ( i.e. from PAR till DRATE both inclusive).
Below is a query to return some rows from the table
Code: |
SELECT
A_U_IND
, MIN(RUN_DATE)
, DRATE
, THOLD
FROM
TABLE1
WHERE
PAR = :TABLE1.PAR
AND BR = :TABLE1.BR
AND ACC = :TABLE1.ACC
AND RUN_DATE BETWEEN :WS-START-DATE AND :WS-END-DATE
AND ITYPE IN ('A' 'B' 'T')
GROUP BY A_U_IND,DRATE,THOLD
ORDER BY THOLD ASC |
In the above query I want to keep everything unchanged but just ensure that the results come in the sorted ascending order of RUN_DATE as well ( in addition to THOLD) . I am trying to put in ORDER by RUN_DATE as well but I am getting a SQL code of -122 . Is there any way this query can be redisgned to provide the same result set with the additional condition of being sorted by RUN_DATE as well.
Any help would be greatly appreciated.
2) Can any one tell me what is the SORT criterial in the above query? I see a trend of the result set being sorted on the basisi of A_U_IND ( when the THOLD are same). Is DB2 engine doing some other sort criteria on its own ? Can we play around with that SORT criteria to get our desired criteria of SORT on basis of RUN_DATE.? |
|