locked
make order for sql statement RRS feed

  • Question

  • dear all

    i have table and i create this statement

    select * from xx order by xx.names,mline(xx.names2,2) into cursor xx2

    the error message tell me the there is an error in order

    what's the error in this line

    Monday, February 27, 2012 9:40 AM

Answers

  • Change the select to

    Select *, mline(names2, 2) as SecondMemoline from xx order by names, SecondMemoLine into cursor xx2

    Assuming names2 is a field and not mline(names,2,2)

    Monday, February 27, 2012 10:32 AM
    Answerer

All replies

  • Change the select to

    Select *, mline(names2, 2) as SecondMemoline from xx order by names, SecondMemoLine into cursor xx2

    Assuming names2 is a field and not mline(names,2,2)

    Monday, February 27, 2012 10:32 AM
    Answerer
  • In Visual FoxPro you can not use a function for the field in the ORDER BY. It means that you either have to include the computed field in the result set and use its alias in the ORDER BY or add this field to the derived table and re-structure the query as

    select field1, field2, etc. from (select *, myComputedColumn from ...) X ORDER BY myComputedColumn


    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog

    Monday, February 27, 2012 10:00 PM
  • Hi,

    to avoid unwanted result better fix the length of SecondMemoLine with :

    Padr(Mline(remark1,2),60,' ')

    where 60 is your desired length

    Regards,

    Koen

    • Marked as answer by Mark Liu-lxf Tuesday, March 6, 2012 8:53 AM
    • Unmarked as answer by Mark Liu-lxf Tuesday, March 6, 2012 8:53 AM
    Monday, February 27, 2012 10:55 PM