久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

ORDER BY select 語句使用 UNION &清楚的

ORDER BY select statement using UNION amp; DISTINCT(ORDER BY select 語句使用 UNION amp;清楚的)
本文介紹了ORDER BY select 語句使用 UNION &清楚的的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在使用以下查詢來填充值的下拉列表.

I'm using the following query to populate a dropdown list of values.

select 'Select a City' as City, 'All' as Value
UNION ALL
select distinct City, City as Value from BND_Listing

我想對結果進行 A-Z 排序.我嘗試了以下方法:

I'd like to sort A-Z the results. I've tried the following:

select 'Select a City' as City, 'All' as Value
UNION ALL
select distinct City, City as Value from BND_Listing
ORDER BY City ASC

但是我收到一個錯誤:

關鍵字聯合"附近的語法不正確.

Incorrect syntax near the keyword 'Union'.

此外,此查詢正在提取Blank or NULL"值并在下拉列表頂部顯示一個空格.如果可能的話,我想隱藏它.不顯示任何空值?

Additionally this query is pulling "Blank or NULL" values and displaying a blank space at the top of the drop-down. I'd like to hide that if possible. Not display any null value?

推薦答案

感謝大家的回復,它們讓我對在哪里查找問題有了很多見解.添加以下內容的原始查詢獲得了正確的結果.

Thank you everyone for the responses it gave me a lot of insight on where to look for my problem. The original query with the addition of the below achieved the proper result.

工作查詢:

select 'Select a City' as City, 'All' as Value
UNION ALL
select distinct City, City as Value from BND_Listing
where isnull(City,'') <> ''
Order by City ASC

選擇城市"始終位于下拉列表的頂部.感謝@scsimon 在我的另一篇文章中對此的貢獻.

with 'Select a City' always at the top of the dropdown. Credit to @scsimon on my other post for this.

with cte as(
select 'Select a City' as City, 'All' as Value
UNION ALL
select distinct City, City as Value from BND_Listing
where isnull(City,'') <> '')


select * from cte  Order by case when City = 'Select a City' then 1 else 2     end, City ASC

這篇關于ORDER BY select 語句使用 UNION &amp;清楚的的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Modify Existing decimal places info(修改現有小數位信息)
The correlation name #39;CONVERT#39; is specified multiple times(多次指定相關名稱“CONVERT)
T-SQL left join not returning null columns(T-SQL 左連接不返回空列)
remove duplicates from comma or pipeline operator string(從逗號或管道運算符字符串中刪除重復項)
Change an iterative query to a relational set-based query(將迭代查詢更改為基于關系集的查詢)
concatenate a zero onto sql server select value shows 4 digits still and not 5(將零連接到 sql server 選擇值仍然顯示 4 位而不是 5)
主站蜘蛛池模板: 久久久久久久久久久久亚洲 | 91视频在线 | 成人欧美一区二区三区在线播放 | 欧洲精品久久久久毛片完整版 | 亚洲aⅴ | 91在线第一页 | 6080亚洲精品一区二区 | 欧美亚洲国产一区二区三区 | 久草网站| 久久久青草婷婷精品综合日韩 | 国产一区二区三区四区五区加勒比 | 国产二区在线播放 | 日韩精品成人免费观看视频 | 国产精品亚洲综合 | 国产超碰人人爽人人做人人爱 | 成人小视频在线观看 | av色站 | 国产午夜久久久 | 国产日韩欧美一区二区 | www.成人免费视频 | 国产精品99久久久久久宅男 | 先锋资源亚洲 | 蜜臀av日日欢夜夜爽一区 | 激情一区二区三区 | 日韩三级电影在线看 | 欧美日韩综合视频 | 国户精品久久久久久久久久久不卡 | 久久久蜜桃 | 国产日韩一区二区三区 | 亚洲精品乱码久久久久久按摩观 | 日本一区二区不卡 | 91精品国模一区二区三区 | 精品在线观看一区二区 | 久久在线免费 | 日韩成人精品一区二区三区 | 国产a区| 99爱国产 | 中文字幕一区二区三区四区五区 | 一区二区三区不卡视频 | 国产十日韩十欧美 | 日韩精品一区二区三区在线观看 |