The "where count = 1" is evaluated first, long before the "order by".  It will 
always return the first row in the table

Karen

 

 

 

-----Original Message-----
From: Michael J. Sinclair <[email protected]>
To: RBASE-L Mailing List <[email protected]>
Sent: Fri, Dec 26, 2014 11:01 am
Subject: [RBASE-L] - Selecting a row using count and order by DESC



Hi All,
I am trying to select values from a row based on count. It seems to work as 
expected when the order is ascending, but nothing changes when I make the order 
descending.


ColA       ColB
-------------------
abc           1
def            2
ghi            3


When I do this....


SELECT ColA into vdata i1 from table where count =1 order by ColB ASC
then I get the variable
vdata = abc


When I do this....


SELECT ColA into vdata from table where count =1 order by ColB DESC *(changed 
ASC to DESC)
then I still get 
vdata = abc  


What I want is to get when the order is DESC
vdata = ghi


What am I doing wrong?
Is what I want possible?
Mike




Reply via email to