我正在编写一个查询,根据计数(TOTALCOUNT)删除表中的某些行。我想删除所有计数< = 5的行。以下是我的询问:
DELETE FROM NSFABSTRACTS WHERE TOTALCOUNT<=5
SELECT WORD, COUNT(WORD) AS TOTALCOUNT FROM NSFABSTRACTS
GROUP BY WORD;
我也试过下面的那个,也没用:
DELETE FROM NSFABSTRACTS
SELECT WORD, COUNT(WORD) AS TOTALCOUNT FROM NSFABSTRACTS
GROUP BY WORD
WHERE TOTALCOUNT<=5;
它给了我这个错误:
Error report:
SQL Error: ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"
*Cause:
。
*Action:
感谢您的帮助。
答案 0 :(得分:1)
DELETE FROM NSFABSTRACTS
WHERE WORD IN (
SELECT WORD FROM NSFABSTRACTS
GROUP BY WORD
HAVING COUNT(*)<=5
)
这将删除所有包含在表格中出现小于等于5次的单词的玫瑰。
答案 1 :(得分:0)
尝试:
DELETE FROM NSFABSTRACTS
WHERE FileID IN
(
SELECT FILEID
FROM NSFABSTRACTS
GROUP BY WORD, FILEID
HAVING COUNT(WORD) <=5;
)
假设文件ID是您的主键。
答案 2 :(得分:0)
尝试:
DELETE FROM NSFABSTRACTS
WHERE FILEID IN
(
SELECT FILEID FROM NSFABSTRACTS
GROUP BY FILEID, WORD
HAVING COUNT(Word)<=5
)
答案 3 :(得分:0)
试试此代码
delete from NSFabstracts where fileID in
(select fileid from nsfabstracts group by word,fileid
having COUNT(word)<=5)