需要有关sql查询的帮助 [英] Need help with the sql query
本文介绍了需要有关sql查询的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含两列statecode和state的表,其值为 -
状态代码状态
1 DLI
2 MH
3 UP
2 DLI
在我的输出中,我只需要那些没有任何重复值的行列,即O / p应该像
状态代码状态
2 MH
3 UP
解决方案
SELECT DISTINCT statecode,state FROM'table'
get重复使用
选择州来自 statetable ,count(*)
group by state
count(*)> 1
那么你可以使用
摆脱它们
选择状态代码,状态来自 statetable
其中州 ()
I have a table with two columns statecode and state having values as-
Statecode state
1 DLI
2 MH
3 UP
2 DLI
In my output i need only those rows that do not have duplicate values in any of the column, I.e., O/p should be like
Statecode State
2 MH
3 UP
解决方案
SELECT DISTINCT statecode, state FROM 'table'
get duplicates using
select state from statetable ,count(*) group by state having count(*) > 1
then you can get rid of them using
select statecode, state from statetable where state not in ()
这篇关于需要有关sql查询的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文