按功能分组会引发错误。我该如何解决
Optional<User> user = userRepository.findOne(withOrderd(order).and(withID(id)));
答案 0 :(得分:0)
GROUP BY仅需要您要汇总的字段:
GROUP BY TO_CHAR(TRANSBDATE,'MON-YYYY')PERIOD, B.CURCODE
所以不是在COUNT(B.CURCODE)
上,而是在CURCODE上
答案 1 :(得分:0)
'use strict';
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const {WebhookClient} = require('dialogflow-fulfillment');
admin.initializeApp({
credential: admin.credential.applicationDefault(),
databaseURL: 'ws://mood-magic-four-ptwvjb.firebaseio.com/'
});
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
function playSadSong (agent) {
// Get the database collection 'dialogflow' and document 'agent'
var randomNumber = Math.floor(Math.random() * 2) + 1;
return admin.database().ref(('`${randomNumber}`') ).once('value').then((snapshot) => {
const song = snapshot.child('song').val();
const artist = snapshot.child('artist').val();
if(song !== null && snapshot.child('sadness').val() > 0.5){
agent.add(`I will play ${song} by ${artist}`);
}
else {
agent.add(`I couldn't find anything right now...`);
}
});
}
// Map from Dialogflow intent names to functions to be run when the intent is matched
let intentMap = new Map();
intentMap.set('-Sad - yes', playSadSong);
agent.handleRequest(intentMap);
});
答案 2 :(得分:0)
您不能在GROUP BY
中包括聚合函数。您只需要SELECT
中的未聚合列。
我建议将查询编写为:
SELECT TO_CHAR(H.TRANSBDATE,'MON-YYYY') as PERIOD,
D.CURCODE,
COUNT(DISTINCT ?.CUSTOMERID) as UNIQUECUSTOMERS,
COUNT(*) as TRANS
FROM FX_TRANSHEADER H JOIN
FX_TRANSDETAIL D
ON H.TRANSNO = D.TRANSNO
WHERE H.TRANSBDATE >= DATE '2018-01-01' AND
H.TRANSBDATE < DATE '2018-07-01' AND
?.C_IDTYPE NOT IN ('CR')
ORDER BY 1 , 4
GROUP BY TO_CHAR(H.TRANSBDATE, 'MON-YYYY');
?
用于具有指定列的表的列别名。
注意:
FROM
子句中使用逗号。 始终使用正确的,明确的,标准 JOIN
语法。DATE
代表日期文字,因此您的代码不会与服务器上的特定国际化设置相关联。BETWEEN
替换为两个直接比较。这在Oracle等数据库中尤其重要,其中DATE
数据类型具有时间分量。