Devan Goodwin wrote:
% -----BEGIN PGP SIGNED MESSAGE-----
% Hash: SHA1
%
% On Tue, 3 Feb 2009 20:24:06 +0100
% Jan Pazdziora <[email protected]> wrote:
%
% > On Tue, Feb 03, 2009 at 02:48:15PM -0400, Devan Goodwin wrote:
% > > FROM rhnSatelliteCert
% > > WHERE label = :label
% > > - - ORDER BY version DESC NULLS LAST
% > > + ORDER BY
% > > + CASE WHEN version IS NULL
% > > + THEN -1
% > > + ELSE version
% > > + END
% > > + DESC
% > >
% > > Holler if you spot any problems.
% >
% > Can't we just use those two fields, in the ORDER BY query?
%
% What two fields?
order by decode(version, null, 1, 0), version
or
order by CASE WHEN version IS NULL
THEN 1
ELSE 0
END, version
% > I do not like that use of -1, which I assume is in the domain of
% > the type of version.
%
% > It might work in this case now but it might
% > confuse people reading the code five years from now, and it might
% > confuse people who will be porting the NULLS LAST construct in
% > situation when the value of choice will actually be a possible
% > value of the column used.
% >
%
% Could you rephrase the last part of this?
Version is number, -1 is number. If there is a record with version = -2
your order by will be messed. Semantics of your order by clause is not equal
to original (NULLS LAST) one.
--
Michael Mráka
Satellite Engineering, Red Hat
_______________________________________________
Spacewalk-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/spacewalk-devel