關於SQL表的問題,求SQL語句

時間 2025-03-03 21:05:12

1樓:

-ms sql server, 類似這樣。

這個是取物料在銷售和採購兩個表一段時間內都沒有記錄的顯示, 你可以根據實際情況修改。

select distinct 物料表。*

from 物料表 a

left join (select * from 銷售明細 where 時間 >=date) b on a.物料號 = b.物料號。

left join (select * from 採購明細 where 時間 >=date) c on a.物料號 = c.物料號。

where b.物料號 is null and c.物料號 is null

2樓:

select *

from 物料表 a

where 1=1

and not exists (select 1from 銷售明細表 b

where b.物料號 = a.物料號。

and b.時間 between @bgntime and @endtime

and not exists (select 1from 採購明細表 b

where b.物料號 = a.物料號。

and b.時間 between @bgntime and @endtime

3樓:網友

select 物料號,物料名 from 物料表 where 物料號 not in(select 物料號 from 銷售表) and 物料號 not in (select 物料號 from 採購表)

各位高手,幫一下忙,這是一道考試試題,要用sql語句寫出基本表,如下

4樓:網友

這幾題的sql語句如下:

姓名 from 職工 where 年齡》45參加。職工號 from 社會團體,參加 where 社會團體。編號=參加。編號 and 社會團體。名稱='藍球隊'

職工號 from 職工 where not exists(select 1 from 參加 where 參加。職工號=職工。職工號)

名稱 from 社會團體 order by 名稱名稱,count(1) as 人數 from 社會團體 group by 名稱。

sql查詢語句的問題,sql語句關於查詢的問題

select d,count from select day 訪問時間 d,ip位址,count from 訪問記錄表 where year 訪問時間 2008 and month 訪問時間 5 group by 1,2 一 如果你的資料庫伺服器獲取日期時間欄位的日數 1 31 不是day,請你修改...

SQL語句問題,SQL語句問題

select identity int,1,1 as newid,sale.prtid as id,products.prtname as 商品名稱,sum sale.prtnum as 銷售總量 into a from sale,products where sale.prtid products...

sql語句問題

你那個4,是怎麼樣的乙個4,是這裡面的那個4的結果,還是4行那個4.如果是那個4的結果,那麼就再套一層max一下,或者後後面按照c的倒敘,取rownum 1都行。如果是4行那個4,那麼你上面就沒必要count,把group by 去掉,直接寫count distinct kitsproduc0 ty...