问题一:
     select f1,f2 f3 from table1
     f1按升序  f2按降序排列这样的sql 怎么写?
     求助关于string的函数,取子串,取前n个字符、取中间字符串、取后n个字符串

解决方案 »

  1.   

    select f1,f2 f3 from table1 order by f1,f2 desc判斷子串S1是否存在S2中,返回為存在的位置,不存在返回0  : PatIndex(S1,S2)
    substring(S,1,2)  left(S,2)   right(S,2)
      

  2.   

    select f1, f2, f3 from table1 order by f1 Asc, f2 Desc
      

  3.   

    select f1,f2,f3 from table1 order by f1,f2 desc
    截字符串函数:
    SQL Server 是:
    Substring(Str,x,y);
    Str为原字符串,x为起始位置,y为要截的子串长度。
    Delphi是
    Copy(Str,x,y);参数一样。
      

  4.   

    select f1,f2,f3 from table1 order by f1 asc,f2 dec