这可能是一个愚蠢的新手问题,但是我试图弄清楚如何订购东西。
您将如何构造一个SQL语句,以便在具有ORDERDATE属性的表ORDERING中,我可以看到每个日期有多少订单?
我知道下面的查询是按日期进行组织的,但是我想知道每个日期有多少重复,以便查找一天中有多少订单。
reportServiceRequest rq = new reportServiceRequest();
rq.loginId = "admin@xxxxx.com";
rq.password = "xxxxxxx";
rq.orgId = 1;
rq.reportRequest = "RUNDASHBOARDREPORT";
rq.reportId = reportId;
rq.orgIdSpecified = true;
rq.dashboardTabId = 11111;
rq.dashboardTabIdSpecified = true;
rq.reportIdSpecified = true;
rq.dashboardTabId = tabId;
using (var srv = new ServiceReference2.LegacyReportServiceClient())
{
YellowFinIntegrationWithDotNet.ServiceReference2.reportServiceResponse resp = null;
try
{
resp = srv.remoteReportCall(rq); // there is no "remoteAdministrationCall" as in the doc
}
catch (System.Exception ex)
{
MessageBox.Show(ex.InnerException.ToString());
return resp;
}
return resp;
}
答案 0 :(得分:2)
Count是一个聚合函数,因此您必须对要聚合的属性进行GROUP BY。
SELECT ORDERDATE,COUNT(*)
FROM ORDERING
GROUP BY ORDERDATE
ORDER BY ORDERDATE DESC;
制作问题。
答案 1 :(得分:1)
SELECT ORDERDATE,COUNT(*)
FROM ORDERING
GROUP BY ORDERDATE
HAVING COUNT(*)>1