>> to query for maximum value
Posted in 1994
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL
I would appreciate any recommendations or ideas on the following problem I am having .... I have two tables oer and oer_detail with oer being the master of oer_detail. Following are the fields in each table: oer.oer_no type serial, indexed unique oer_detail.oer_no type integer, indexed dupl oer_detail.item_no type smallint, indexed dupl oer_detail.item_ltr type char, indexed dupl I have 2 composite indexes defined for table oer_detail: duplicate index on (oer_no, item_no) unique index on (oer_no, item_no, item_ltr) The following records are contained in table oer_detail: oer_no item_no item_ltr 1 1 1 1 a 1 1 b 1 1 c 1 2 1 3 1 4 2 1 2 1 a 2 1 b 2 2 2 2 a 2 2 b I am running with Informix Version 2.10.03G (4GL is unavailable) and want to be able to use the >> option available to find the maximum value in the item_no field with a specific oer_no. When running my form I am doing a QUERY and typing my search criteria : OER NO: [1 ] ITEM NO: [>> ] ITEM LTR: [ ] and expect the form to display item no 4 as the max. Likewise I would like OER NO: [2 ] ITEM NO: [>> ] ITEM LTR: [ ] to display item no 2 as the max. Currently Informix displays ITEM NO 4 as the max when I run the query for OER NO 1, because OER NO 1 contains the maximum ITEM NO of all records contained in the oer_detail table. When I run the second query example from above Informix tells me there are no rows satisfying the conditions. Please send any ideas or alternative solutions to: cott@letterkenn-emh1.army.mil Thanks!!!!!