Re: Sorting Integer
Posted in 1993
Alan Popiel <alan@den.mmc.com> writes in response to the following 2 messages: ->Date: Wed, 17 Feb 93 15:58:11 MST ->From: Cathy Kipp <ckipp@vth1.vth.colostate.edu> ->Subject: Re: Sorting Integer ->To: informix-list@rmy.emory.edu -> ->Ruchi, -> ->For sorting by the last two digits of an integer, how about: -> ->select integer_num, -> -(trunc(integer_num, -2) - integer_num) ->from table_name ->order by 2 -> ->The trunc function with a precision of -2, will change the last two digits of ->the number to zeroes. Then subtracting your original number from this ->truncated number and changing the sign will give you a column containing the ->last two digits of your original number which you can then sort by. -> ->Hope this is of some use! -> ->Cathy ->From: aland@informix.com (Colonel Panic) ->Message-Id: <1993Feb18.025701.26297@informix.com> ->Subject: Re: Sorting integer field ->Date: 18 Feb 93 02:57:01 GMT -> ...omitted... -> ->OR, in SQL, IF you have a 5.XX engine product, you can take advantage ->of the mod() function: -> ->select intfield, mod(intfield, 100) last2 from tablename ->order by last2 -> ->Alan Denney aland@informix.com {pyramid|uunet}!infmx!aland -> Cathy, What version of Informix ISQL/ACE/engine/etc. are you running? I looked for the TRUNC function in my 4.00 (and 4.10 supplement) manuals and did not see it. Is it an ACE feature? I know you use ACE a lot, while I don't use it at all. I see that Alan Denney tells us that MOD became available in v5.00 of the engine. I work on several platforms, running everything from 2.10.03F ISQL and 1.10.03F 4GL (both fossils), to 4.00 and 4.10 4GL running against 5.XX engines. Feature creep is a real problem for me. I really like the BEFORE MENU, HIDE OPTION, and SHOW OPTION available in 4.10 4GL, but when I tried to port an application containing them to a system still running 4.00, it died big time. See you at the user group meeting, -Alan