//自定義排序
SELECT CNO_CODE FROM ODMDOC T1
WHERE CNO_CODE IN ('0970000319','0970000320','0970000321','0970000322')
ORDER BY
(SELECT CASE T1.CNO_CODE when '0970000321' then 0
when '0970000320' then 1
when '0970000322' then 2
when '0970000319' then 3 end)
strSQL += " AND T1.CNO_CODE IN (" & strCNO_CODES & ") "
Dim strArrCNO_CODE As String()
Dim strORDERBY As New StringBuilder
strORDERBY.AppendLine(" ORDER BY (SELECT CASE T1.CNO_CODE ")
strArrCNO_CODE = Split(strCNO_CODES, ",")
For j As Int16 = 0 To strArrCNO_CODE.Length - 1
strORDERBY.AppendLine(" WHEN " & strArrCNO_CODE(j) & " THEN " & j)
Next
strORDERBY.AppendLine(" END) ")
strSQL += strORDERBY.ToString