我有一张这样的表:
S.No | (C1) | (C2) | (C3) | (C1+C2+C3)
-----------------------------------------------
1 | 2 | 4 | 5 | (I want 11 here)
-----------------------------------------------
2 | 5 | 2 | 0 | (I want 7 here)
-----------------------------------------------
如何为此编写SQL查询?
任何人请帮助我。
提前致谢。
答案 0 :(得分:0)
试试这句话。
select ROW_NUMBER() OVER(ORDER BY c1 DESC) AS SerialRowNum, c1,c2,c3, (c1 + c2 c3) as Total from table
答案 1 :(得分:0)
posudo看起来像:
private class get_txt_from_url extends AsyncTask<String , Void , String>{
final String TAG = "get_txt_from_url";
@Override
protected String doInBackground(String... params) {
InputStream is = null;
BufferedReader reader = null;
StringBuilder string_builder = null;
String line ="";
try {
HttpClient hc = new DefaultHttpClient();
HttpPost hp = new HttpPost(params[0]);
HttpResponse hr = hc.execute(hp);
HttpEntity htity = hr.getEntity();
is = htity.getContent();
} catch (IOException e) {
Log.d(TAG , "ZERO");
}
try {
reader = new BufferedReader(new InputStreamReader(is , "utf-8") , 8);
string_builder = new StringBuilder();
} catch (UnsupportedEncodingException e) {
Log.d(TAG, "ONE");
}
try {
while((line = reader.readLine()) != null){
string_builder.append(line+"");
}
} catch (IOException e) {
Log.d(TAG, "line");
}
return string_builder.toString();
}
@Override
protected void onPostExecute(String s) {
Log.d(TAG , s);
}
}
答案 2 :(得分:0)
如果要在列值中使用它,请使用下表中的VIRTUAL
列。
Create table your_table_name
(C1 number,
C2 number,
C3 number,
"C1+C2+C3" NUMBER GENERATED ALWAYS AS (C1+C2+C3) VIRTUAL)
现在,oracle将负责为您生成所需的值。
干杯!