select b1.* from (select top 12 val(hip_no) as MyValue, hip_no as MyKey from stnhorse where Amount > 0 order by 1 desc) a1
inner join stnhorse b1 on a1.MyKey = b1.hip_no
order by a1.MyValue ASC
into cursor MyResult


Just a WAG, but basically I'm having the subselect do the criteria selecting, and the outer select do the ordering.

hth,
--Mike


On 9/23/2013 11:16 AM, James Harvey wrote:
Here is how I get the last 12 horses sold to appear in a grid in order by
hip number ascending.

"Hip_no" is a character field, but they want it to show as a "number", with
no leading zeros.  The "amount" field gets an amount posted as each horse is
sold at the auction.

Is it possible to get the return set in one select statement?

Example:
Hip#
2300
2301
2302
2303
2304
Etc., etc.




***returns the last 12 horse sold but in hip number descending order.

Select ;
        Top 12 ;
        hip_no as hip, ;
        Val(hip_no) As hip_no, ;
        Name, ;
        Alltrim(Alltrim(sbfname) + " " + Alltrim(sblname)) As signby, ;
        amount ;
        From ;
        stnhorse ;
        Where ;
        amount > 0 ;
        Order By ;
        hip_no Desc ;
        Into Cursor (Thisform.r_temp)




***reverses hip number order of last 12 horse returned in above select
statement.

Select ;
        hip, ;
        hip_no, ;
        Name, ;
        signby, ;
        amount ;
        From ;
        (Thisform.r_temp) ;
        Order By ;
        hip  ;
        Into Cursor (Thisform.r_lcfile)







James E Harvey
M.I.S.
Hanover Shoe Farms, Inc.
www.hanoverpa.com
office: 717-637-8931
cell: 717-887-2565
fax: 717-637-6766



[excessive quoting removed by server]

_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/52405e53.5010...@mbsoftwaresolutions.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to