sql - 如何从sql中的相同值中选择1条记录?
问题描述
我有一张customer
桌子:
我必须显示客户姓名才能选择出售。名称可以重复,我必须选择带有客户名称的记录。如何选择该特定记录?
我正在使用以下查询:
select tot_amt
from customer
where cust_name = 'someone'
解决方案
虽然您应该使用cust_id
来显示结果,因为每个结果cust_id
都是唯一的,但是如果您只想显示 1 row
,即使结果中rows
有超过1 个,那么您可以使用query
:
select top 1 tot_amt from customer where cust_name='someone';
推荐阅读
- python - 是否可以将另一级键迭代地添加到字典中以生成嵌套字典?
- android - 在片段中实现 setOnClickListener 时出现空指针异常
- python - Python Dictionary - 如何找到具有最少唯一值的所有键?
- excel - 使用 .Net 核心将数据表导出到 Excel
- r - 当 HTML 文件已存在时,Rmd 输出格式未在 blogdown 中正确编译
- javascript - 按 id 或 Date JavaScript 排序 JSON
- microsoft-graph-api - 备用更新日历事件未显示 Microsoft 团队链接
- javascript - JS:函数运行太快但不想使用 setTimeout 的快速补丁
- wcf - 使用证书连接时 WCF 请求引发错误
- python - Tensor("dense_2/Softmax:0", shape=(?, 10), dtype=float32) 不是该图的元素