嗨選擇,我有以下SQL存儲過程查詢如何下令列的#在SQL查詢
@colindex int
SELECT
di.folio,
di.name,
di.region,
di.amount
FROM datainfo di
WHERE di.isactive = 1
ORDER BY [email protected] 'where colindex is the index of the column returned
例子:
如果@colindex = 1則列,我想順序是「folio」列。
如果@colindex = 4,那麼我想要排序的列是「amount」列。
關於如何在SQL中處理此問題的任何線索?
謝謝。
也可能有@ordertype(asc或desc)並將其添加到查詢中? – VAAA 2013-02-19 17:42:49
@VAAA ....是的:-) – 2013-02-19 17:51:20
關於如何做到這一點的任何線索?非常感謝你的幫助! – VAAA 2013-02-19 17:53:24