情况:有三个字段,companyid,goodsid,year,一个companyid有多个goodsid,帮我写一段SQL,找出companyid中的goodsid在2023年有记录,2022没有记录
时间: 2023-04-09 18:01:29 浏览: 104
company.sql
SELECT DISTINCT companyid FROM table_name WHERE goodsid IN (SELECT goodsid FROM table_name WHERE year = 2023) AND companyid NOT IN (SELECT companyid FROM table_name WHERE year = 2022)
阅读全文