>Dear Experts
>
>Table1 has four fields as
>
>code n(4)
>name n(4)
>amount n(5)
>type c(1)
>
>Data in fields is as
>
>code----name----amount--type
>1101----Eric-----100-----B
>1202----Bill-------200-----B
>1506----Boris----600-----A
>1608----Cetin----900-----A
>1709----Jack-----800-----A
>2101----Ali--------900-----B
>2202----Tame---100-----A
>2608----Zahi-----100-----A
>
>I need following output based on two conditions
>
>Group + type
>Every group is based on First digit of code
>Type is based on A and B
>
>Codes between 1100 to 1900 is Group 1
>Codes between 2000 to 2900 is Group 2 and so on
>
>This should be Final Output
>
>code----name----amount--type
>2--------2-------300------B && total of group 1 with type=B
>3--------3-------1700-----A && total of group 1 with type=A
>1--------1-------900------B && total of group 2 with type=B
>2--------2-------200------A && total of group 2 with type=A
>
>
>Please help
select ;
icase( ;
between(code, 1100,1900), 1, ;
between(code, 2000,2900), 2, ;
3) as myGroup, type, sum(amount) as totAmt from myTable group by 1,2
Cetin