회사 목록을 표시하는 SELECT 문이 있습니다.SQL select 문에 ALL을 추가하십시오.
SELECT distinct [Company]
FROM [Records]
"ALL"항목을 반환 된 목록의 첫 번째 항목으로 어떻게 추가 할 수 있습니까?
실제로select company
from ((select distinct company, 1 as ordering from records)
union all
(select 'ALL', 0)
) t
order by ordering;
는 것 같다 다음 작업 :
select 'ALL' as company
union all
select distinct company from records;
그러나, SQL 서버는 그렇지 않습니다
가'UNION'를 참조하십시오. 그러나 보장 결과를 얻으려면 전체 결과 집합을 기술적으로 ORDER BY해야합니다. 참고 http://blog.sqlauthority.com/2012/10/30/sql-server-union-all-and-order-by-how-to-order-table-separately-while-using-union-all/ – user2864740