### Type Decimal identity crisis

Posted:

**Sat Jun 30, 2018 8:05 am**Code: Select all

```
VAR TESTD PRIVATE INIT(
REL{TUP{ID 1,D Decimal(5.5,2)},
TUP{ID 2,D Decimal(7.0,0)},
TUP{ID 3,D Decimal(7.0,0)},
TUP{ID 4,D Decimal(7.0,0)},
TUP{ID 5,D Decimal(14.5,2)},
TUP{ID 6,D Decimal(23.5,2)},
TUP{ID 7,D Decimal(23.5,2)},
TUP{ID 8,D Decimal(35.5,2)},
TUP{ID 9,D Decimal(42.5,2)}}
)KEY{ID};
//SAME D RECOGNIZED AS UNIQUE.
WRITELN TESTD{D};
/*
RELATION {D Decimal} {
TUPLE {D Decimal(5.5, 2)},
TUPLE {D Decimal(7.0, 0)},
TUPLE {D Decimal(7.0, 0)},
TUPLE {D Decimal(7.0, 0)},
TUPLE {D Decimal(14.5, 2)},
TUPLE {D Decimal(23.5, 2)},
TUPLE {D Decimal(23.5, 2)},
TUPLE {D Decimal(35.5, 2)},
TUPLE {D Decimal(42.5, 2)}}
*/
//SAME D RECOGNIZED AS UNIQUE.
WRITELN TESTD GROUP{ID} AS GRP EXTEND {CNT:=COUNT(GRP)} ORDER(ASC D);
/*
ARRAY {D Decimal, GRP RELATION {ID INTEGER}, CNT INTEGER} {
TUPLE {D Decimal(5.5, 2), GRP RELATION {ID INTEGER} {
TUPLE {ID 1}
}, CNT 1},
TUPLE {D Decimal(7.0, 0), GRP RELATION {ID INTEGER} {
TUPLE {ID 2}
}, CNT 1},
TUPLE {D Decimal(7.0, 0), GRP RELATION {ID INTEGER} {
TUPLE {ID 4}
}, CNT 1},
TUPLE {D Decimal(7.0, 0), GRP RELATION {ID INTEGER} {
TUPLE {ID 3}
}, CNT 1},
TUPLE {D Decimal(14.5, 2), GRP RELATION {ID INTEGER} {
TUPLE {ID 5}
}, CNT 1},
TUPLE {D Decimal(23.5, 2), GRP RELATION {ID INTEGER} {
TUPLE {ID 7}
}, CNT 1},
TUPLE {D Decimal(23.5, 2), GRP RELATION {ID INTEGER} {
TUPLE {ID 6}
}, CNT 1},
TUPLE {D Decimal(35.5, 2), GRP RELATION {ID INTEGER} {
TUPLE {ID 8}
}, CNT 1},
TUPLE {D Decimal(42.5, 2), GRP RELATION {ID INTEGER} {
TUPLE {ID 9}
}, CNT 1}}
*/
//D RECOGNIZED AS BOTH IDENTITICAL AND UNIQUE.
WRITELN TESTD{D} RANK(ASC D AS R) ;
/*
RELATION {D Decimal, R INTEGER} {
TUPLE {D Decimal(5.5, 2), R 1},
TUPLE {D Decimal(7.0, 0), R 2},
TUPLE {D Decimal(7.0, 0), R 2},
TUPLE {D Decimal(7.0, 0), R 2},
TUPLE {D Decimal(14.5, 2), R 3},
TUPLE {D Decimal(23.5, 2), R 4},
TUPLE {D Decimal(23.5, 2), R 4},
TUPLE {D Decimal(35.5, 2), R 5},
TUPLE {D Decimal(42.5, 2), R 6}}
*/
//D VALUES NOT RECOGNIZED, NO VALUES.
WRITELN SUMMARIZE TESTD BY{D}:{CNT:=COUNT()};
/*
RELATION {D Decimal, CNT INTEGER} {
TUPLE {D Decimal(5.5, 2), CNT 1},
TUPLE {D Decimal(7.0, 0), CNT 0},
TUPLE {D Decimal(7.0, 0), CNT 0},
TUPLE {D Decimal(7.0, 0), CNT 0},
TUPLE {D Decimal(14.5, 2), CNT 0},
TUPLE {D Decimal(23.5, 2), CNT 0},
TUPLE {D Decimal(23.5, 2), CNT 0},
TUPLE {D Decimal(35.5, 2), CNT 0},
TUPLE {D Decimal(42.5, 2), CNT 0}}
//NO D VALUES.
WRITELN SUMMARIZE TESTD BY{D}:{MAXID:=MAX(ID)};
/*
RELATION {D Decimal, MAXID INTEGER} {
TUPLE {D Decimal(5.5, 2), MAXID 1}ERROR: RS0263: Result of MAX on no values is undefined.
*/
```