gpt4 book ai didi

grails - 错误:列 “this_.date”必须出现在GROUP BY子句中或在聚合函数中使用

转载 作者:行者123 更新时间:2023-12-02 14:50:19 25 4
gpt4 key购买 nike

   ERROR: column "this_.date" must appear in the GROUP BY clause or be used in an aggregate function
Position: 296. Stacktrace follows:
org.postgresql.util.PSQLException: ERROR: column "this_.date" must appear in the GROUP BY clause or be used in an aggregate function
Position: 296
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2161)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1890)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:559)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:302)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
at grails.orm.PagedResultList.<init>(PagedResultList.java:53)
at grails.orm.HibernateCriteriaBuilder.invokeMethod(HibernateCriteriaBuilder.java:1511)
at com.rsa.ci.TestResultsService.getProductVersionsWithCriteria(TestResultsService.groovy:501)
at com.rsa.ci.TestResultsService.getBuildStatusHomePageResults(TestResultsService.groovy:568)
at com.rsa.ci.BuildStatusController$_closure11.doCall(BuildStatusController.groovy:219)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

code from line No. 501 where the error is pointing the line number from -->


def reqProductVersions = TestRuns.createCriteria().list(max: reqNumberOfRecords, offset: startIndex) {
projections {
groupProperty "productVersion"
}
'in'("testType",filters.testTypes)
'in'("testSuiteName",suites)
eq("product",filters.product)
like("branch",filters.branch)
like("deploymentMode",filters.deploymentMode)
if(filters.tag){
isNotNull("tag")
ne("tag","")
}
if(!filters.jenkinsInstance.equals("%%")){
processedJenkinsRuns{
like("jenkinsServer",filters.jenkinsInstance)
}
}
cache true
order("date","desc")
}
// we need total count. createcriteria has issue when we ask total count with group property combined
def totalCount = TestRuns.createCriteria().get {
projections {
countDistinct "productVersion"
}
'in'("testType",filters.testTypes)
'in'("testSuiteName",suites)
eq("product",filters.product)
like("branch",filters.branch)
like("deploymentMode",filters.deploymentMode)
if(filters.tag){
isNotNull("tag")
ne("tag","")
}
if(!filters.jenkinsInstance.equals("%%")){
processedJenkinsRuns{
like("jenkinsServer",filters.jenkinsInstance)
}
}
cache true
}
def productVersionAndCount = [:];

productVersionAndCount.put("total",totalCount);
productVersionAndCount.put("productVersions",reqProductVersions);
return productVersionAndCount;

}

def getAllTemplateNames(def productVersions){
def templatesResults = ArtifactsInformation.findAllByP4ChangeListNumInList(productVersions);
Map<String, List<String>> templates = new HashMap<String, List<String>>();

templatesResults.each{ tmp ->
List<String> tempList = templates.get(tmp.p4ChangeListNum);
if(tempList == null){
tempList = new ArrayList<String>();
templates.put(tmp.p4ChangeListNum, tempList)
}
tempList.add(tmp.templateName);
}
return templates;
}

def getBuildStatusHomePageResults(int startIndex,int reqNumberOfRecords,BuildParamsDTO filters, def isCompareChecked){

**568 ->** def productVersionsAndCount = filters.junitAndSeleniumFilter?getProductVersionWithJunitAndSeleniumAndCriteria(filters,startIndex,reqNumberOfRecords):getProductVersionsWithCriteria(filters,startIndex,reqNumberOfRecords);

def productVersions = productVersionsAndCount.get("productVersions");

int totalRecords = productVersionsAndCount.get("total");

log.debug productVersions.toString()+" are selected as required product versions in getData"

Collections.sort(productVersions,Collections.reverseOrder());

Map<String, VersionDto> buildResults = new LinkedHashMap<String, VersionDto>();

productVersions.each{changeList ->
buildResults.put(changeList, new VersionDto(changeList))
}

if(productVersions.size() > 0){
getTestResults(productVersions, filters, buildResults);
}

def reqGroups = filters.testTypes;

def reqSuites =filters.testSuites ;

def dataToRender = [:]

dataToRender = buildDataTableObject(buildResults, reqGroups, reqSuites, filters, totalRecords, isCompareChecked);

return dataToRender;


}

谁能告诉我这实际上意味着什么以及为什么我会收到此错误。

最佳答案

您的条件似乎有常见的聚合问题,因此您选择的字段必须出现在group by子句中。

您可以尝试在 groupProperty 中定义“ date ”,否则可以进行子查询聚合,然后合并要显示的其他列。

从此answer获得帮助

希望这可以帮助。谢谢

关于grails - 错误:列 “this_.date”必须出现在GROUP BY子句中或在聚合函数中使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33413296/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com