我一直在通过电子邮件与我们的编码人员在另一个办公室工作,我们已经使用此代码了解了一下。每当我尝试执行查询时,我都会遇到oracle错误。以下是我正在使用的代码:
SELECT TALLY_TRAN_MSTR.SHIFT_DT, TALLY_TRAN_MSTR.LOGON_ID, TALLY_TRAN_MSTR.PRI_GRP_CD,
SUM(case TALLY_TRAN_MSTR.PRI_GRP_CD
WHEN 'PUT' THEN TALLY_TRAN_MSTR.FULL_PLLT_QTY
ELSE 0
END) AS Puts,
SUM(TALLY_TRAN_MSTR.FULL_PLLT_QTY) AS SUM(TALLY_TRAN_MSTR.FULL_PLLT_QTY)
FROM WBR_RW.TALLY_TRAN_MSTR
GROUP BY TALLY_TRAN_MSTR.SHIFT_DT, TALLY_TRAN_MSTR.LOGON_ID
HAVING ((Puts/(SUM(TALLY_TRAN_MSTR.FULL_PLLT_QTY))) > 0.75)
ORDER BY TALLY_TRAN_MSTR.SHIFT_DT, TALLY_TRAN_MSTR.LOGON_ID;
这有什么问题可能会导致错误吗?任何反馈都将不胜感激!
答案 0 :(得分:2)
在这里利用一些甜蜜的甜蜜别名:
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int main()
{
struct aboveAverage
{
string name9;
double percentage1;
};
struct average
{
string name10;
double percentage2;
};
struct belowAverage
{
string name11;
double percentage3;
};
int numOfteams;
double userInput;
cout << "How many teams do you want to store? ";
cin >> numOfteams;
cin.get();
aboveAverage * arrayOfAboveAverage = new aboveAverage[numOfteams];
average * arrayOfAverage = new average[numOfteams];
belowAverage * arrayOfbelowAverage = new belowAverage[numOfteams];
for (int i = 0; i < numOfteams; i++)
{
start:
int x = i + 1;
string name5;
cout << "Enter the name of the team " << x << ":";
getline(cin, name5);
cout << "Enter the team " << x << " percentage: ";
cin >> userInput;
cin.get();
if (userInput >= 66 && userInput <= 100)
{
arrayOfAboveAverage[i].percentage1 = userInput;
arrayOfAboveAverage[i].name9 = name5;
}
else if (userInput <= 66 && userInput >= 33)
{
arrayOfAverage[i].name10 = name5;
arrayOfAverage[i].percentage2 = userInput;
}
else if (userInput <= 33 && userInput >= 0)
{
arrayOfbelowAverage[i].name11 = name5;
arrayOfbelowAverage[i].percentage3 = userInput;
}
else
{
cout << "Percent cannot be greater than 100" << endl;
goto start;
}
}
cout << "Above Average :" << endl;
for (int j = 0; j < numOfteams; j++)
{
if (arrayOfAboveAverage[j].percentage1 != NULL ||
arrayOfAboveAverage[j].name9 != "")
{
cout << arrayOfAboveAverage[j].name9 <<" ";
cout << arrayOfAboveAverage[j].percentage1 <<"%"<< endl;
}
else
{
cout << "None" << endl;
}
}
cout << "Average :" << endl;
for (int j = 0; j < numOfteams; j++)
{
if (arrayOfAverage[j].percentage2 > 0 ||
arrayOfAverage[j].name10 != "")
{
cout << arrayOfAverage[j].name10 <<" ";
cout << arrayOfAverage[j].percentage2 <<"%"<<endl;
}
else
{
cout << "None" << endl;
}
}
cout << "Below Average : "<< endl;
for (int k = 0; k < numOfteams; k++)
{
if (arrayOfbelowAverage[k].percentage3 > 0 ||
arrayOfbelowAverage[k].name11 != "")
{
cout << arrayOfbelowAverage[k].name11 << " ";
cout << arrayOfbelowAverage[k].percentage3 <<"%"<< endl;
}
else
{
cout << "None" << endl;
}
}
delete[] arrayOfAboveAverage;
delete[] arrayOfAverage;
delete[] arrayOfbelowAverage;
return 0;
}
了解这对您有何帮助。更改是最后一个列别名,SELECT T.SHIFT_DT,
T.LOGIN_ID,
T.PRI_GRP_CD,
SUM(CASE WHEN T.PRI_GRP_CD = 'PUT'
THEN T.FULL_PLLT_QTY
ELSE 0
END) AS Puts,
SUM(T.FULL_PLLT_QTY) AS SUM_PLLT_QTY
FROM WBR_RW.TALLY_TRAN_MSTR AS T
GROUP BY T.SHIFT_DT, T.LOGON_ID, T.PRI_GRP_CD
HAVING (SUM(CASE WHEN T.PRI_GRP_CD = 'PUT'
THEN T.FULL_PLLT_QTY
ELSE 0
END) / SUM(T.FULL_PLLT_QTY)) > .75
ORDER BY T.SHIFT_DT, T.LOGON_ID;
子句是显式的。