我的查询没有给出任何结果

时间:2016-01-19 10:20:03

标签: sql ms-access join

似乎有什么问题?

我从每个选择查询中得到了正确的结果,因此我将所有查询放在一起,

但是结合它们,ms access并没有给我结果。

从技术上讲,它仍在努力完成此查询。

你能给我一些提示吗?

SELECT a.*
FROM (SELECT t.* 
      FROM MyTable AS t 
      WHERE t.ID not In (SELECT TOP 8 id     
                         FROM  (SELECT * 
                                FROM MyTable 
                                WHERE subject = "Math" Or subject ="Science")     
                         WHERE StudentID = t.StudentID    
                         ORDER BY TestScore asc, id asc) AS a
WHERE a.ID In (SELECT TOP 4 id
               FROM (SELECT tt.* 
                     FROM MyTable AS tt 
                     WHERE tt.ID not In (SELECT TOP 8 id     
                                         FROM  (SELECT *
                                                FROM MyTable
                                                WHERE subject = "Math" Or subject ="Science")
                                         WHERE StudentID = t.StudentID    
                                         ORDER BY TestScore asc, id asc) AS b
               WHERE b.StudentID = a.StudentID 
               ORDER BY b.TestScore asc, b.id asc);

1 个答案:

答案 0 :(得分:0)

您是否尝试过一次添加一个查询?排除问题?它更容易打破问题并从那里解决它。