SQL 首先选择某个值
SELECT AssetValue
FROM Assets
WHERE (AssetType = 'Country')
非常简单的Select语句,但它输出
Afghanistan
Albania
Algeria
....
How do I make United States and Canada出现在这上面?这可以通过 SQL 实现吗?或者我需要在 ASP 代码中执行某些操作吗?我的PK是INT身份。
SELECT AssetValue
FROM Assets
WHERE (AssetType = 'Country')
Very simple Select Statement, but it outputs
Afghanistan
Albania
Algeria
....
How do I make United States and Canada appear on the top of this? Is this possible with SQL or do I need to do something in my ASP code? My PK is a INT Identity.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您不希望硬编码,最通用的解决方案是使用额外的字段来指示优惠项目。您可以将其称为
OrderPreference
。 OrderPreference 越高,第一个项目就会出现。其他每个项目的 OrderPreference 都为零。查询:从表面上看,资产是一个用于其他事物(不仅仅是国家)的表,因此您可以使用此方法来解决其他资产类型(如果出现)的相同问题。
If you do not wish to hard code, the most generic solution is having an extra field to indicate the preferential items. You would call it
OrderPreference
. The higher OrderPreference, the first the item would appear. Every item else would have OrderPreference equals ZERO. The query:By the looks of it, Assets is a table you use for other things (not only countries), so you could use this approach to solve the same problem for others asset types, if they come up.
给他们一个组ID,所以组1是美国、英国等,组2是世界其他国家,那么你可以做“优先”国家。
Give them a a group ID, so group 1 is US, UK etc, group2 is the rest of the world, then you can do "priority" countries.