HI Cho, When comparing the 2 calculations: FROM SCP DIVIDEBYZEROTHENZERO(SUM(CASE WHEN ('DateConversions'.'Year' = YEAR(TO_DATE({LocalToday}))) THEN ('ParkersTransactions'.'DollarSales') ELSE (0) END) , ((SUM( SUM( CASE WHEN 'DateConversions'.'Year' = YEAR(TO_DATE({LocalToday})) THEN 'ParkersTransactions'.'DollarSales' ELSE 0 END))) OVER()) - SUM(CASE WHEN ('DateConversions'.'Year' = YEAR(Add_Years(TO_DATE({LocalToday}), -1))) THEN ('ParkersTransactions'.'DollarSales') ELSE (0) END) / ((SUM( SUM( CASE WHEN 'DateConversions'.'Year' = YEAR(Add_Years(TO_DATE({LocalToday}), -1)) THEN 'ParkersTransactions'.'DollarSales' ELSE 0 END)) OVER())))*100 DSDLINK REPORT (SUM(CASE WHEN ('DateConversions'.'Year' = YEAR(TO_DATE({LocalToday}))) THEN 'DSDLinkGlobalStoreDepletion'.'Sales' ELSE (NULL) END) / ((SUM( SUM( CASE WHEN 'DateConversions'.'Year' = YEAR(TO_DATE({LocalToday})) THEN 'DSDLinkGlobalStoreDepletion'.'Sales' ELSE 0 END)) OVER())/2) - SUM(CASE WHEN ('DateConversions'.'Year' = YEAR(Add_Years(TO_DATE({LocalToday}), -1))) THEN 'DSDLinkGlobalStoreDepletion'.'Sales' ELSE (NULL) END) / ((SUM( SUM( CASE WHEN 'DateConversions'.'Year' = YEAR(Add_Years(TO_DATE({LocalToday}), -1)) THEN 'DSDLinkGlobalStoreDepletion'.'Sales' ELSE 0 END)) OVER())/2))*100
时间: 2023-09-19 20:10:11 浏览: 132
Hi! It looks like you're asking about a complex calculation formula with multiple functions and conditions. Unfortunately, I'm not familiar with the specific data and context you're referring to, so I'm not able to provide a meaningful response. Could you please provide me with more information or context about what this calculation is for and what you're trying to achieve?
相关问题
# coding=utf-8 # 文件位置: code\cho13\ch13_8_4.py import wx class MyFrame(wx.Frame): def __init__(self): super().__init__(None, title='静态图片控制', size=(300, 300)) self.panel = wx.Panel(parent=self) self.bmps = [wx.Bitmap('images/3.jpg', wx.BITMAP_TYPE_JPG), wx.Bitmap('images/4.jpg', wx.BITMAP_TYPE_JPG), wx.Bitmap('images/1.webp', wx.BITMAP_TYPE_WEBP)] b1 = wx.Button(self.panel, id=1, label='Button1') b2 = wx.Button(self.panel, id=1, label='Button2') self.Bind(wx.EVT_BUTTON, self.on_click, id=1, id2=2) self.image = wx.StaticBitmap(self.panel, bitmap=self.bmps[0]) vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(b1, proportion=1, flag=wx.EXPAND) vbox.Add(b2, proportion=1, flag=wx.EXPAND) vbox.Add(self.image, proportion=3, flag=wx.EXPAND) self.panel.SetSizer(vbox) def on_click(self, event): event_id = event.GetId() if event_id == 1: self.image.SetBitmap(self.bmps[1]) else: self.image.SetBitmap(self.bmps[2]) self.panel.Layout() app = wx.App() frm = wx.Frame frm.Show() app.MainLoop()
这段代码存在一些错误,无法正常运行。以下是错误的修正:
1. 缺少括号:`frm = wx.Frame`应该改为`frm = MyFrame()`
2. EVT_BUTTON绑定错误:应该是`self.Bind(wx.EVT_BUTTON, self.on_click, id=1)`和`self.Bind(wx.EVT_BUTTON, self.on_click, id=2)`,分别绑定id为1和2的按钮。
3. 图片路径错误:需要将图片放在与代码同级的images文件夹下。
修正后的代码如下:
```python
# coding=utf-8
# 文件位置: code\cho13\ch13_8_4.py
import wx
class MyFrame(wx.Frame):
def __init__(self):
super().__init__(None, title='静态图片控制', size=(300, 300))
self.panel = wx.Panel(parent=self)
self.bmps = [wx.Bitmap('images/3.jpg', wx.BITMAP_TYPE_JPG),
wx.Bitmap('images/4.jpg', wx.BITMAP_TYPE_JPG),
wx.Bitmap('images/1.webp', wx.BITMAP_TYPE_WEBP)]
b1 = wx.Button(self.panel, id=1, label='Button1')
b2 = wx.Button(self.panel, id=2, label='Button2')
self.Bind(wx.EVT_BUTTON, self.on_click, id=1)
self.Bind(wx.EVT_BUTTON, self.on_click, id=2)
self.image = wx.StaticBitmap(self.panel, bitmap=self.bmps[0])
vbox = wx.BoxSizer(wx.VERTICAL)
vbox.Add(b1, proportion=1, flag=wx.EXPAND)
vbox.Add(b2, proportion=1, flag=wx.EXPAND)
vbox.Add(self.image, proportion=3, flag=wx.EXPAND)
self.panel.SetSizer(vbox)
def on_click(self, event):
event_id = event.GetId()
if event_id == 1:
self.image.SetBitmap(self.bmps[1])
else:
self.image.SetBitmap(self.bmps[2])
self.panel.Layout()
app = wx.App()
frm = MyFrame()
frm.Show()
app.MainLoop()
```
class Question: def __init__(self, stem, options, answer): self.stem = stem self.options = options self.answer = answerclass QuestionBank: def __init__(self): self.questions = [] def add_question(self, question): self.questions.append(question) def remove_question(self, question): self.questions.remove(question) def get_random_questions(self, num): return random.sample(self.questions, num)class Paper: def __init__(self, questions): self.questions = questions self.answers = {} def answer_question(self, question, answer): self.answers[question] = answer def get_score(self): score = 0 for question, answer in self.answers.items(): if answer == question.answer: score += 1 return scoreclass Grader: def __init__(self, paper): self.paper = paper def grade(self): return self.paper.get_score()# Example usagequestion1 = Question("What is the capital of France?", ["Paris", "London", "Berlin", "Madrid"], "Paris")question2 = Question("What is the largest planet in the solar system?", ["Mercury", "Venus", "Earth", "Jupiter"], "Jupiter")question3 = Question("What is the highest mountain in the world?", ["K2", "Mount Everest", "Makalu", "Cho Oyu"], "Mount Everest")question_bank = QuestionBank()question_bank.add_question(question1)question_bank.add_question(question2)question_bank.add_question(question3)paper = Paper(question_bank.get_random_questions(2))paper.answer_question(question1, "Paris")paper.answer_question(question2, "Jupiter")grader = Grader(paper)score = grader.grade()print("Your score is:", score)将这个代码转为C++的
好的,以下是将 Python 代码转换为 C++ 代码的示例:
```cpp
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <random>
using namespace std;
class Question {
public:
string stem;
vector<string> options;
string answer;
Question(string s, vector<string> o, string a) {
stem = s;
options = o;
answer = a;
}
};
class QuestionBank {
public:
vector<Question> questions;
void add_question(Question q) {
questions.push_back(q);
}
void remove_question(Question q) {
questions.erase(remove(questions.begin(), questions.end(), q), questions.end());
}
vector<Question> get_random_questions(int num) {
vector<Question> res;
random_device rd;
mt19937 gen(rd());
shuffle(questions.begin(), questions.end(), gen);
for (int i = 0; i < num; ++i) {
res.push_back(questions[i]);
}
return res;
}
};
class Paper {
public:
vector<Question> questions;
map<Question, string> answers;
Paper(vector<Question> q) {
questions = q;
}
void answer_question(Question q, string a) {
answers[q] = a;
}
int get_score() {
int score = 0;
for (auto const& x : answers) {
if (x.second == x.first.answer) {
score++;
}
}
return score;
}
};
class Grader {
public:
Paper paper;
Grader(Paper p) {
paper = p;
}
int grade() {
return paper.get_score();
}
};
int main() {
Question question1("What is the capital of France?", {"Paris", "London", "Berlin", "Madrid"}, "Paris");
Question question2("What is the largest planet in the solar system?", {"Mercury", "Venus", "Earth", "Jupiter"}, "Jupiter");
Question question3("What is the highest mountain in the world?", {"K2", "Mount Everest", "Makalu", "Cho Oyu"}, "Mount Everest");
QuestionBank question_bank;
question_bank.add_question(question1);
question_bank.add_question(question2);
question_bank.add_question(question3);
vector<Question> random_questions = question_bank.get_random_questions(2);
Paper paper(random_questions);
paper.answer_question(question1, "Paris");
paper.answer_question(question2, "Jupiter");
Grader grader(paper);
int score = grader.grade();
cout << "Your score is: " << score << endl;
return 0;
}
```
注意,这只是一个简单的示例,实际情况下可能需要更多的代码来处理错误处理、用户输入等问题。
阅读全文