這樣的sql怎麼寫

2022-12-22 15:31:20 字數 849 閱讀 2320

1樓:匿名使用者

with tmp(a,b) as(

select 'a1',1 union allselect 'a1',0 union allselect 'a2',1 union allselect 'a2',2 union allselect 'a3',2 union allselect 'a3',0

)select distinct t1.a from tmp t1left join tmp t2 on t1.a=t2.a and t2.b=0

where t2.a is null

結果如下:

2樓:石門程式猿

很簡單一句話搞定!希望能幫到你

select * from table where a not in(select distinct a from table where b='0' )

2.如果是這樣的表呢?查詢出b列中不包含0且c列為r的條件下的a列的值,例如上圖只要求顯示結果還是為a2

如果是這樣的話

select * from table where a not in(select distinct a from table where b='0' ) and c='r'

3樓:我行我素的兔子

select a from table where a not in (select a from table where b =0)

4樓:匿名使用者

select distinct a from tab where a not in (select distinct a from tab where b=0)

sql語句怎麼寫

delete from s where sname 張三 這是把名字是張三的所有使用者全部刪除了,不建議這麼刪除,因為可能重名。delete from s where id 3,這是刪除了單獨一行的資料,你可以吧你要刪除張三前面的id號取出來,建議這麼刪除。如果不對,請勿噴,謝謝。既然你要徹底刪除張...

怎么寫sql語句刪除重複項,怎麼寫sql語句刪除重複項

create table t tmp as select from select t.row number over partition by t.fullname,t.address order by t.fullname seq form enterprise t where seq 1 在 o...

這樣的請柬怎麼寫,求教這樣的結婚請柬怎麼寫被邀請方是已婚人士的用這款式的請柬又是怎麼寫

我沒結婚,沒寫過請柬,可我見過,你就寫 某公司某科室的全體職員 大概就是這個意思,你可以考慮做電子請柬,發他們的郵箱,或者從 上發過去,如果需要我可以幫你,發彩信請柬也行,我都會做 求教這樣的結婚請柬怎麼寫?被邀請方是已婚人士的用這款式的請柬又是怎麼寫?15 那你是打算邀請對方夫妻倆,全家,還是單獨...