【发布时间】:2021-05-04 01:49:21
【问题描述】:
我有这样的表:
id account_no tax date
1 201 10 2021-01-31
2 201 0 2021-01-31
3 301 20 2021-01-31
4 401 20 2020-10-10
我想要 account_no 的不同值,同时具有 tax <> 0 和 date = '2021-01-31'
预期结果:
account_no
201
301
我应该如何查询? 我正在使用 Visual Studio 13。
我正在查询:
Select distinct Account_No from (
Select Account_No, date, count(*) jumlah from table
Where date = '2021-01-31' and tax <> 0
Group By Account_No, date
Having count(*) > 1
) a
但结果一直显示不同的 account_no 和重复的日期
【问题讨论】:
-
到目前为止,您尝试做什么?你能分享一些你的努力吗?
-
顺便说一句,我猜到Visual Studio会与mssql server结合使用
-
@FranciscodeCastro 即时编辑查询
-
@hifanaya,查询真的很简单,就像你描述的那样。已经有一个有效的答案
标签: mysql sql group-by distinct