我是使用谷歌图表的新手,我无法弄清楚为什么我的查询没有显示在我的谷歌图表(表格)中。然而,表显示另一个查询。我试图显示的查询没有显示像我的第一个查询那样的表。
我似乎无法理解问题所在,因为我多次测试了我的查询,甚至在SQL Server中运行它,它确实生成了我要查找的输出,但它根本没有显示在表中
工作查询:
SELECT Researcher.FirstName + ' ' + Researcher.Surname AS [Researcher_Name], Count(Submission.SubmissionID) AS [Number_of_Submissions] FROM Submission INNER JOIN ((Faculty INNER JOIN School ON Faculty.FacultyID = School.[FacultyID]) INNER JOIN (Researcher INNER JOIN ResearcherSubmission ON Researcher.ResearcherID = ResearcherSubmission.ResearcherID) ON School.SchoolID = Researcher.SchoolID) ON Submission.SubmissionID = ResearcherSubmission.SubmissionID GROUP BY Researcher.FirstName, Researcher.Surname;
这是不显示Google图表的查询。 注意:当我在SQL生成器中运行此查询时,它会显示我要查找的结果:
SELECT Submission.Title AS [Title], Submission.Status AS [Submission_Status] FROM Submission INNER JOIN ((Faculty INNER JOIN School ON Faculty.FacultyID = School.[FacultyID]) INNER JOIN (Researcher INNER JOIN ResearcherSubmission ON Researcher.ResearcherID = ResearcherSubmission.ResearcherID) ON School.SchoolID = Researcher.SchoolID) ON Submission.SubmissionID = ResearcherSubmission.SubmissionID GROUP BY Submission.Status, Submission.Title;
这是我的完整代码和工作查询,我已经注释掉了不工作的代码:
@{
var db = Database.Open("RMSContext");
String rows = "";
var Query = ("SELECT Researcher.FirstName + ' ' + Researcher.Surname AS [Researcher_Name], Count(Submission.SubmissionID) AS [Number_of_Submissions] FROM Submission INNER JOIN ((Faculty INNER JOIN School ON Faculty.FacultyID = School.[FacultyID]) INNER JOIN (Researcher INNER JOIN ResearcherSubmission ON Researcher.ResearcherID = ResearcherSubmission.ResearcherID) ON School.SchoolID = Researcher.SchoolID) ON Submission.SubmissionID = ResearcherSubmission.SubmissionID GROUP BY Researcher.FirstName, Researcher.Surname;");
//var Query = ("SELECT Submission.Title AS [Title], Submission.Status AS [Submission_Status] FROM Submission INNER JOIN ((Faculty INNER JOIN School ON Faculty.FacultyID = School.[FacultyID]) INNER JOIN (Researcher INNER JOIN ResearcherSubmission ON Researcher.ResearcherID = ResearcherSubmission.ResearcherID) ON School.SchoolID = Researcher.SchoolID) ON Submission.SubmissionID = ResearcherSubmission.SubmissionID GROUP BY Submission.Status, Submission.Title;");
var AppQuery = db.Query(Query);
List<string> rowsList = new List<string>();
foreach (var item in AppQuery)
{
rowsList.Add("['" + item.Researcher_Name + "', " + item.Number_of_Submissions + "]");
};
rows = String.Join(", ", rowsList);
}
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1.1", { packages: ["table"] });
google.setOnLoadCallback(drawTable);
function drawTable() {
var data = google.visualization.arrayToDataTable([
['Researcher Name', 'Number of Submissions'],
@Html.Raw(rows)]);
var options = {
title: ''
};
var dashboard = new google.visualization.Dashboard(document.querySelector('#dashboard'));
var stringFilter = new google.visualization.ControlWrapper({
controlType: 'StringFilter',
containerId: 'string_filter_div',
options: {
filterColumnIndex: 0
}
});
var table = new google.visualization.ChartWrapper({
chartType: 'Table',
containerId: 'table_div',
options: {
showRowNumber: false
}
});
dashboard.bind([stringFilter], [table]);
dashboard.draw(data);
}
google.load('visualization', '1', { packages: ['controls'], callback: drawTable });
</script>
<div id="dashboard">
<div id="string_filter_div"></div>
<div id="table_div"></div>
</div>
我觉得我错过了一些非常简单的东西,但却无法说谎。
答案 0 :(得分:2)
首先,您最不需要GROUP BY
,因此删除行GROUP BY Submission.Status, Submission.Title;
可能您不需要GROUP BY
,而是意味着使用{ {1}}功能和您的ROW_NUMBER()
完全奇怪,修改如下
JOINS