请用SQL 语句实现:从testdb 数据表中查询出所有月份的发生额都比101科目相应月份的发生额高的科目。
时间: 2024-02-17 17:05:27 浏览: 107
好的,以下是查询语句:
```sql
SELECT *
FROM testdb
WHERE (Jan > (SELECT Jan FROM testdb WHERE subject = '101'))
AND (Feb > (SELECT Feb FROM testdb WHERE subject = '101'))
AND (Mar > (SELECT Mar FROM testdb WHERE subject = '101'))
AND (Apr > (SELECT Apr FROM testdb WHERE subject = '101'))
AND (May > (SELECT May FROM testdb WHERE subject = '101'))
AND (Jun > (SELECT Jun FROM testdb WHERE subject = '101'))
AND (Jul > (SELECT Jul FROM testdb WHERE subject = '101'))
AND (Aug > (SELECT Aug FROM testdb WHERE subject = '101'))
AND (Sep > (SELECT Sep FROM testdb WHERE subject = '101'))
AND (Oct > (SELECT Oct FROM testdb WHERE subject = '101'))
AND (Nov > (SELECT Nov FROM testdb WHERE subject = '101'))
AND (Dec > (SELECT Dec FROM testdb WHERE subject = '101'))
```
这个查询语句会返回所有月份的发生额都比101科目相应月份的发生额高的科目。其中,testdb是您要查询的表名,Jan到Dec是月份对应的列名,'101'是您要比较的科目。
阅读全文