如何将 order by 添加到语句中

How to add order by into statement

有谁知道如何将 order by 插入到下面的语句中

SELECT ctr_num,
       scn
FROM   user_convoy
WHERE  ctr_num LIKE '%" + str_convoy + "%'"

不太确定你的问题,但据我了解,应该是:

select ctr_num , scn from user_convoy where ctr_num like '%" + str_convoy + "%'" ORDER BY your_column

最后添加ORDER BY。 SELECT 语句的一般格式通常是 SELECT FROM WHERE ORDER BY(当然假设没有分组)。注意不区分大小写。

select ctr_num , scn from user_convoy where ctr_num like '%' + str_convoy + '%' ORDER BY ctr_num

ORDER BY 关键字用于按一列或多列对结果集进行排序。

如果您想使用 Order By,请尝试以下操作。

SELECT ctr_num,
       scn
FROM   user_convoy
WHERE  ctr_num LIKE '%' + str_convoy + '%'
ORDER BY
       ctr_num,scn

更多详情:

请参考w3schools Example and to learn in more depth this