How can I retrive the top 3 rated events MySQL
I have sporting events that users can rate. All data is stored in a Mysql
database.
Ratings_table:
rating_id PK
organisation float
value_for_money float
fun_factor float
facilities float
event_id int
user_id int
Event_table:
event_id PK
event_name varchar
Is there a way I can use Mysql query to join the tables and order them so
that the 3 highest rated events are retrieved?
Thursday, 3 October 2013
Wednesday, 2 October 2013
Need help writing an int to roman numeral converter using only if, if else, and switch statements
Need help writing an int to roman numeral converter using only if, if
else, and switch statements
Here is the code:
public String ToRoman(int number) {
if ((number < 1 || (number > 3999)))
if (number >= 1000) return "M" + ToRoman(number - 1000);
if (number >= 900) return "CM" + ToRoman(number - 900);
if (number >= 500) return "D" + ToRoman(number - 500);
if (number >= 400) return "CD" + ToRoman(number - 400);
if (number >= 100) return "C" + ToRoman(number - 100);
if (number >= 90) return "XC" + ToRoman(number - 90);
if (number >= 50) return "L" + ToRoman(number - 50);
if (number >= 40) return "XL" + ToRoman(number - 40);
if (number >= 10) return "X" + ToRoman(number - 10);
if (number >= 9) return "IX" + ToRoman(number - 9);
if (number >= 5) return "V" + ToRoman(number - 5);
if (number >= 4) return "IV" + ToRoman(number - 4);
if (number >= 1) return "I" + ToRoman(number - 1);
Scanner myKeyboard = new Scanner (System.in);
System.out.println("Enter the integer: ");
number = myKeyboard.nextInt();
myKeyboard.close();
} }
The problem im having is that i get an error saying "The method must
return a result type string".
else, and switch statements
Here is the code:
public String ToRoman(int number) {
if ((number < 1 || (number > 3999)))
if (number >= 1000) return "M" + ToRoman(number - 1000);
if (number >= 900) return "CM" + ToRoman(number - 900);
if (number >= 500) return "D" + ToRoman(number - 500);
if (number >= 400) return "CD" + ToRoman(number - 400);
if (number >= 100) return "C" + ToRoman(number - 100);
if (number >= 90) return "XC" + ToRoman(number - 90);
if (number >= 50) return "L" + ToRoman(number - 50);
if (number >= 40) return "XL" + ToRoman(number - 40);
if (number >= 10) return "X" + ToRoman(number - 10);
if (number >= 9) return "IX" + ToRoman(number - 9);
if (number >= 5) return "V" + ToRoman(number - 5);
if (number >= 4) return "IV" + ToRoman(number - 4);
if (number >= 1) return "I" + ToRoman(number - 1);
Scanner myKeyboard = new Scanner (System.in);
System.out.println("Enter the integer: ");
number = myKeyboard.nextInt();
myKeyboard.close();
} }
The problem im having is that i get an error saying "The method must
return a result type string".
How to Convert a tab delimited file with commas in values to .CSV and the values with commas to be enclosed in double quotes?
How to Convert a tab delimited file with commas in values to .CSV and the
values with commas to be enclosed in double quotes?
I have a .CSV file (Lets say tab_delimited_file.csv) that I download from
a web portal of a particular vendor. When I moved the file to one of my
Linux directories, I noticed that this particular .CSV file is actually a
tab delimited file which is named as .CSV. Please find below few sample
records of the file.
"""column1""" """column2""" """column3""" """column4"""
"""column5""" """column6""" """column7"""
12 455 string with quotes, and with a comma in between 4432 6787
890 88
4432 6787 another, string with quotes, and with two comma in between
890 88 12 455
11 22 simple string 77 777 333 22
The above sample records are separated by tabs. I know the header of the
file is very weird but this is the way I received the file format to be.
I tried to use tr command to replace the tabs with commas but the file
gets messed up completely due to the extra commas in the record values. I
need the record values with commas in them to be enclosed in double
quotes. The command I used is as below.
tr '\t' ',' < tab_delimited_file.csv > comma_separated_file.csv
This converts the file into the below format.
"""column1""","""column2""","""column3""","""column4""","""column5""","""column6""","""column7"""
12,455,string with quotes, and with a comma in between,4432,6787,890,88
4432,6787,another, string with quotes, and with two comma in
between,890,88,12,455
11,22,simple string,77,777,333,22
I need help to convert the sample file into the below format.
column1,column2,column3,column4,column5,column6,column7
12,455,"string with quotes, and with a comma in between",4432,6787,890,88
4432,6787,"another, string with quotes, and with two comma in
between",890,88,12,455
11,22,"simple string",77,777,333,22
Any solution in either using sed or awk will be very useful.
values with commas to be enclosed in double quotes?
I have a .CSV file (Lets say tab_delimited_file.csv) that I download from
a web portal of a particular vendor. When I moved the file to one of my
Linux directories, I noticed that this particular .CSV file is actually a
tab delimited file which is named as .CSV. Please find below few sample
records of the file.
"""column1""" """column2""" """column3""" """column4"""
"""column5""" """column6""" """column7"""
12 455 string with quotes, and with a comma in between 4432 6787
890 88
4432 6787 another, string with quotes, and with two comma in between
890 88 12 455
11 22 simple string 77 777 333 22
The above sample records are separated by tabs. I know the header of the
file is very weird but this is the way I received the file format to be.
I tried to use tr command to replace the tabs with commas but the file
gets messed up completely due to the extra commas in the record values. I
need the record values with commas in them to be enclosed in double
quotes. The command I used is as below.
tr '\t' ',' < tab_delimited_file.csv > comma_separated_file.csv
This converts the file into the below format.
"""column1""","""column2""","""column3""","""column4""","""column5""","""column6""","""column7"""
12,455,string with quotes, and with a comma in between,4432,6787,890,88
4432,6787,another, string with quotes, and with two comma in
between,890,88,12,455
11,22,simple string,77,777,333,22
I need help to convert the sample file into the below format.
column1,column2,column3,column4,column5,column6,column7
12,455,"string with quotes, and with a comma in between",4432,6787,890,88
4432,6787,"another, string with quotes, and with two comma in
between",890,88,12,455
11,22,"simple string",77,777,333,22
Any solution in either using sed or awk will be very useful.
Tuesday, 1 October 2013
Max Character in JSON Parsing
Max Character in JSON Parsing
What is the max char in json parsing, and how to display large text like
800 char?
{
"employees": [
{
"firstName": "John",
"desc": null
},
{
"firstName": "Anna",
"desc": null
},
{
"firstName": "Peter",
"desc": null
}
]
}
I have problem when my database has 900 char the "JSON" showed null.
What is the max char in json parsing, and how to display large text like
800 char?
{
"employees": [
{
"firstName": "John",
"desc": null
},
{
"firstName": "Anna",
"desc": null
},
{
"firstName": "Peter",
"desc": null
}
]
}
I have problem when my database has 900 char the "JSON" showed null.
Print command line output into a text file in Linux (Ubuntu)
Print command line output into a text file in Linux (Ubuntu)
I have a C++ program in Linux (Ubuntu) which prints very long output in a
command terminal.
How can i copy this output from command terminal directly to the .txt file
by Linux command?
I have a C++ program in Linux (Ubuntu) which prints very long output in a
command terminal.
How can i copy this output from command terminal directly to the .txt file
by Linux command?
Mod_cache is not logging or caching
This summary is not available. Please
click here to view the post.
Is this an open set in $(C([0,1]), \left\|{\cdot}\right\|_p)$?
Is this an open set in $(C([0,1]), \left\|{\cdot}\right\|_p)$?
Let $A=\{g\in C([0,1]):\int_{0}^{1}|g(x)|dx<1\}$. If $p\in [0,\infty]$, is
$A$ an open set of $(C([0,1]), \left\|{\cdot}\right\|_p)$?
Is it obvious that if $p=1$ then $A$ is open in $(C([0,1]),
\left\|{\cdot}\right\|_1)$, because $A=B(0,1)$.
I think $A$ is not open if $p>1$. Any hint to show this?
Thanks.
Let $A=\{g\in C([0,1]):\int_{0}^{1}|g(x)|dx<1\}$. If $p\in [0,\infty]$, is
$A$ an open set of $(C([0,1]), \left\|{\cdot}\right\|_p)$?
Is it obvious that if $p=1$ then $A$ is open in $(C([0,1]),
\left\|{\cdot}\right\|_1)$, because $A=B(0,1)$.
I think $A$ is not open if $p>1$. Any hint to show this?
Thanks.
Subscribe to:
Comments (Atom)