當前位置:首頁 » 編程語言 » sqlselect不重復
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

sqlselect不重復

發布時間: 2022-01-15 00:44:25

sql查詢不重復的記錄

select * from test
where id not in (
select id from test inner join
(
select proctname,procttype,count(*) as counts from test group by proctname,procttype
having count(*)>1
)as a on test.proctname=a.proctname and test.procttype=a.procttype
)
試試這個

② 求sql顯示(查詢)不重復數據命令

必須有唯一標識列才能過濾重復,下面給你個思路:

生成唯一id列:
select id=identity(1,1),bianhao、name、jiage、chandi、shuliang into #tmp_tb from 表1

查詢顯示name不重復的所有數據:
select * from #tmp_tb t1 where not exists (select 1 from #tmp_tb t2 where t2.name=t1.name and t2.id<t1.id)

bianhao列為唯一標示列,顯示大的小的都可以
--------------------
那直接查就可以了:
select * from kucun t1 where not exists (select 1 from kucun t2 where t2.name=t1.name and t2.bianhao<t1.bianhao)

③ sql 查詢不重復的數據

--下面是查詢出有重復ID的數據,具體的刪除你自己弄,因為主從表關系限制,我就不寫刪除語句啦,你自己看情況刪除
select * from proct_info
where id in (select id from proct_info
group by type_id
)

select id from proct_info_pic
where infoid in (select id from proct_info
group by type_id )

④ 求助SQl Select不重復的記錄

select a.id, a.name,a.location, a.memo , b.cnt
from 表 a ,
(select name,min(id) as id , count(id) as cnt
from 表
group by name ) b
where a.id = b.id

-----------------------
裡面的』表『這個部分寫你的表名,2個都是一樣的名字

⑤ sql語句選不重復的值的問題。

select B.*
from (
select 設備ID, max(維護時間) as ModTime
from tableA group by 設備ID
) A
Left join tableA B on A.設備ID=B.設備ID and A.ModTime = B.維護時間

您好,這樣寫應該就是你要的.

⑥ sql 查詢不重復記錄

SQL查詢不重復記錄,操作如下:
1、假如要查詢t1表中name欄位中所有的姓名,並去除重復。
2、可以使用如下語句:
SELECT DISTINCT name FROM t1;3、其中DISTINCT是去重功能。

⑦ 「sql」怎麼查詢不重復數據

1、select distinct 查詢欄位名 。

2、查詢from 表名 。


3、設置where 查詢條件。

4、輸入distinct是去除重復內容的。

⑧ SQL對不重復項進行計數

那如果要不重復的,就要把分組去掉,語句改成:
select count(Distinct Class)as Class from ClassDate where Machine='020-C03' and DateTime='2014-7-18'

⑨ SQL查詢不重復數據語句

打開sql2008資料庫,無論哪個版本都行,方法和語句都是一樣的

選擇默認資料庫為我們需要查詢的資料庫,輸入SQL語句的時候,就會出現只能提示窗口

在這個表中,我們要統計同一個部門包含多少條記錄

語句【select distinct BELONG_DPID from BED】可以查詢出不同的部門有10個,如圖所示

對語句進行完善,統計每個部門的行數
select distinct BELONG_DPID,COUNT(BELONG_DPID) from BED

查詢結果如圖所示,這樣就篩選出各個部門的記錄數