将 CAST() 与 MAX()/MIN() 结合使用
我有一些街道号码存储为 VARCHAR,但我想尽可能将它们排序为 INT。这种语法被接受,但会产生 alpha 排序集,例如 max = 53, min = 1203
SELECT `StreetName`,
CAST( MIN( `StreetNumber` ) AS UNSIGNED) as min,
CAST( MAX( `StreetNumber` ) AS UNSIGNED) as max
FROM `tblAddToLotBridge`
WHERE `LotNumber` = '$item_lotnum'
AND `Primary_Secondary` = 0
GROUP BY `StreetName`
ORDER BY `StreetName`
我尝试将 CAST()
嵌套在 MIN()
/MAX()< /code> 但该语法被拒绝。
DWIM 的正确语法是什么?
I have some street numbers stored as VARCHARs but I want to sort them where possible as INTs. This syntax is accepted but produces alpha sorted sets like max = 53, min = 1203
SELECT `StreetName`,
CAST( MIN( `StreetNumber` ) AS UNSIGNED) as min,
CAST( MAX( `StreetNumber` ) AS UNSIGNED) as max
FROM `tblAddToLotBridge`
WHERE `LotNumber` = '$item_lotnum'
AND `Primary_Secondary` = 0
GROUP BY `StreetName`
ORDER BY `StreetName`
I tried nesting CAST()
inside of MIN()
/MAX()
but that syntax got rejected.
What is the correct sytax to DWIM?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是你尝试过的吗?
Is this what you tried?