rs = s.executeQuery("SELECT Class1_predicted, Class2_predicted, Class3_predicted, Class_predicted"
+ SUM(PROFIT_LOSS) AS "Total Profit",
+ "FROM xxxxxx "
+ "WHERE CLASS1_PREDICTED = curr_class1_predicted, CLASS2_PREDICTED = curr_class2_predicted, CLASS3_PREDICTED = curr_class3_predicted, CLASS_PREDICTED = curr_class_predicted,"
+ "PROFIT_LOSS >= 0,"
+ "GROUP BY Class1_predicted, Class2_predicted, Class3_predicted,Class_predicted");
rs.next();
int recordCount = rs.getInt(1);
myConsole.getOut().println("Number of records in subset of table xxxxx where P/L >= 0: " + recordCount);
I am getting an error on the AS in the second line ?
Not sure how to correct ?
Bob M
You should put the whole query in a String.
It seems like here you are not actually quoting the expression:
+ SUM(PROFIT_LOSS) AS "Total Profit",
It should be something like this:
+ "SUM(PROFIT_LOSS) AS Total_Profit,"
Related
I'm working on a ROBLOX game and trying to add an intermission. It should wait until the round is over then change its text to an Int countdown. Here's my script:
TeamChange = game.StarterGui.TeamChange
LobbyBar = game.StarterGui.LobbyBar
TimeWaited = 0
TeamChange.Enabled = false
LobbyBar.TextLabel.Text = "Please Wait for Next Round!"
GameEnded = true
if GameEnded == true then
TeamChange.Enabled = true
repeat
LobbyBar.TextLabel.Text = "Intermission: " + TimeWaited + " Seconds"
TimeWaited = TimeWaited + 1
delay(1)
until TimeWaited == 10
else
LobbyBar.TextLabel.Text = "Please Wait for Next Round!"
TeamChange.Enabled = false
end
The error pops up on this line LobbyBar.TextLabel.Text = "Intermission: " + TimeWaited + " Seconds"
Also if it's important the GUIs are childs of StarterGui and this script is in SeverScriptService.
The problem is that you're trying to sum text rather than concatenate it. In lua, to concatenate text, the syntax is ... So instead of "Intermission: " + TimeWaited + " Seconds", you should use "Intermission: " .. TimeWaited .. " Seconds".
I'm a noob trying to learn python 3 and I'm trying to include the half_age as a string without using directly writing the number 9 as a string but I couldn't figure it out.
I've tried:
print = str(18//2)
print = int(18//2)
print = float(18/2)
my_age = 18
half_age = (18//2)
name = "Kenny!"
greeting = "Kia Ora, "
print(greeting + name)
print("Your age is " + my_age + "and half your age is " + str(half_age ))
print("Your age is " + my_age + "and half your age is " + str(half_age ))
TypeError: can only concatenate str (not "int") to str
Try formatting all of your numbers with str ie.
my_age = 18
half_age = (18//2)
name = "Kenny!"
greeting = "Kia Ora, "
print(greeting + name)
print("Your age is " + str(my_age) + " and half your age is " + str(half_age))
Just use modern f-strings:
my_age = 18
half_age = (18//2)
name = "Kenny"
greeting = "Kia Ora"
print(f'{greeting}, {name}!')
print(f"Your age is {my_age} and half your age is {half_age}")
or
print(f"Your age is {my_age} and half your age is {my_age/2}")
recently, i tried to do some pig script with groovy, here is my code
def appID = ['pub000000', 'pub000004', 'pub000001', 'pub000004'] as Object[]
before :appInfo = new Object[4]
now: **def appInfo = ['info1','info2','info3','info4']**
for (int i = 0; i < appInfo.size(); i++) {
//Load all the related appInfo tables
pigServer.registerQuery("${appInfo[i]} = LOAD'hbase://Information.${appID[i]}' " +
"USING org.apache.pig.backend.hadoop.hbase.HBaseStorage('meta:number1 " +
"meta:number2') " +
"AS (number1:chararray, number2:chararray);")
}
pigServer.registerQuery("totalAppinfo = UNION ${appInfo[0]},${appInfo[1]},${appInfo[2]},${appInfo[3]};")
I worked it out finally, just to give the array the value.
Complete guess (never used piglatin), but does this work?
def appID = ['pub000000', 'pub000004', 'pub000001', 'pub000004']
appID.each { id ->
pigServer.registerQuery( "${id} = LOAD'hbase://Information.${id}' " +
"USING org.apache.pig.backend.hadoop.hbase.HBaseStorage('meta:number1 " +
"meta:number2') " +
"AS (number1:chararray, number2:chararray);")
}
pigServer.registerQuery("totalAppinfo = UNION ${appId.join(',')};")
Edit after update to question:
def appID = ['pub000000', 'pub000004', 'pub000001', 'pub000004']
def appInfo = ['info1','info2','info3','info4']
[appInfo,appID].transpose().each { info, id ->
pigServer.registerQuery( "${info} = LOAD'hbase://Information.${id}' " +
"USING org.apache.pig.backend.hadoop.hbase.HBaseStorage('meta:number1 " +
"meta:number2') " +
"AS (number1:chararray, number2:chararray);")
}
pigServer.registerQuery("totalAppinfo = UNION ${appInfo.join(',')};")
This is my code
for (int m=0; m < i ; m++){
ta1.setText( s[m].getName().toString() + ", " + s[m].getProgramName().toString() + ", " + s[m].getUni1() + ", " + s[m].getUni2() + ", " + s[m].getUni3() + ", " );
}
It's supposed to print a line from an array of student ( called s) into a JTextArea ( called ta1 ). the problem is that it always only prints the last student in the array.
I need to print each student in a new line. could anyone help me sort it out?
When you set text on an element, the current position in the loop will take over the last one.
Try doing this.
String s = "";
for(int m = 0, m <i; m++){
s += s[m].getName.toString() + ", " + s[m].getprogramName().toString() + "\n;
}
ta1.setText(s);
Create a string and add each entry to it then add new line to end of each entry "\n"
Then do.
ta1.setText(s);
setText overwrites whatever is the current text.
You need append instead; you also need a "\n" at the end of a line.
I am doing this in java, but the answer isn't java specific.
Here is my code:
String map = " x " +
" x o xxxx xxxx xxxx " +
" x xxxx " +
" xxxx xxxx " +
" xx xxxxxx " +
" xx " +
" xx " +
" xx x " +
" xx x " +
" xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ";
for(int i = 0; i < map.length(); i++) {
if(map.charAt(i) == 'x') {
platform[i] = CCSprite.sprite("platform_2.gif");
platform[i].setPosition(x, y); //How to get x and y?
addChild(platform[i]);
platformCount++;
}
}
As you can see, for every "x" in the map string, I want to create a new platform. Now, each line of the string is 57 characters long, and I need to get the X and Y value of where that X is, but all I can retrieve is the charAt the "i" variable, in the for statement. What is a logical way to do this?
int x = i % width;
int y = i / width;
…where % is modulo and / is integer division.