with temp as (select * from doris_fdbfault_QBMonitor_OA where vin in (select distinct vin from vin_packID_pairing_v2 where substr(packID,6,3)='VB6')), result_detail as (select day,vin,Flag_RositivetoGroundISOR,Counts_RositivetoGroundISOR,ST_RositivetoGroundISOR,ET_RositivetoGroundISOR, Flag_NegativetoGroundISOR,Counts_NegativetoGroundISOR,ST_NegativetoGroundISOR,ET_NegativetoGroundISOR from temp t1 where day>='2023-07-01' and vin not in (select distinct vin from temp t1 where t1.day<t1.day)) select count(*) from result_detail where day='2023-07-01' 帮忙修改下这段代码
时间: 2024-04-17 17:23:41 浏览: 391
根据你提供的代码,我看到了一个问题,就是在子查询中使用了相同的表别名 `t1`。为了修复这个问题,你可以更改其中一个子查询的表别名。
以下是修改后的代码:
```sql
WITH temp AS (
SELECT *
FROM doris_fdbfault_QBMonitor_OA
WHERE vin IN (
SELECT DISTINCT vin
FROM vin_packID_pairing_v2
WHERE SUBSTR(packID, 6, 3) = 'VB6'
)
),
result_detail AS (
SELECT day, vin, Flag_RositivetoGroundISOR, Counts_RositivetoGroundISOR, ST_RositivetoGroundISOR, ET_RositivetoGroundISOR,
Flag_NegativetoGroundISOR, Counts_NegativetoGroundISOR, ST_NegativetoGroundISOR, ET_NegativetoGroundISOR
FROM temp t1
WHERE day >= '2023-07-01' AND vin NOT IN (
SELECT DISTINCT vin
FROM temp t2
WHERE t2.day < t1.day
)
)
SELECT COUNT(*)
FROM result_detail
WHERE day = '2023-07-01';
```
我将第一个子查询中的表别名从 `t1` 修改为了 `t2`,以便与外部查询的别名区分开来。
请注意,这只是根据你提供的代码进行的修改,如果还有其他问题,请提供更多详细信息,我将尽力帮助你。
阅读全文
相关推荐



















