数据库值分离

时间:2012-04-06 08:25:36

标签: java database resultset

我正在开发一个创建图表的应用程序。 我有两种类型的查询。
类型1 仅返回一个值[Double]
类型2 返回多个值[字符串,值]

我已经包含了两个样本结果

  

类型1:
住院死亡率   
1.7879989
    
  类型2:   
药物不良反应无:
不良反应药物不良反应56
不良反应药物不良反应67
不良反应后不良反应31因逆转事件不良后输血反应32

我想分开字符串&值。建议欢迎。
我的质询:

SELECT WMSNAB_MAIN_DESCRIPTION MAIN,WNSNAC_DETAIL_DESCRIPTION DETAIL,
COUNT(WMSNAD_PATIENT_ID) PID
FROM WMSNAB_INCIDENT_MASTER A,WMSNAC_INCIDENT_DETAIL B, 
WMSNAD_PATIENT_INCIDENTS C,WMSNAE_PAT_INCI_DET D
WHERE A.WMSNAB_MAIN_CODE       = B.WMSNAC_MAIN_CODE
AND B.WMSNAC_DETAIL_CODE     = D.WMSNAE_INCIDENT_DETAIL_CODE
AND C.WMSNAD_TRANS_ID = D.WMSNAE_TRANS_ID
AND TO_CHAR(C.WMSNAD_TRANS_DATE,'YYYY') = '2011'
AND A.WMSNAB_MAIN_CODE = 'A'
GROUP BY WMSNAB_MAIN_DESCRIPTION, WNSNAC_DETAIL_DESCRIPTION
UNION
SELECT WMSNAB_MAIN_DESCRIPTION MAIN,WNSNAC_DETAIL_DESCRIPTION DETAIL,
COUNT(WMSNAE_TRANS_ID) PID
FROM WMSNAB_INCIDENT_MASTER A,WMSNAC_INCIDENT_DETAIL B, WMSNAE_PAT_INCI_DET D
WHERE A.WMSNAB_MAIN_CODE       = B.WMSNAC_MAIN_CODE
AND B.WMSNAC_DETAIL_CODE     = D.WMSNAE_INCIDENT_DETAIL_CODE
AND TO_CHAR(D.WMSNAE_OCCURRED_DATE_TIME,'YYYY') = '2011'
AND A.WMSNAB_MAIN_CODE = 'A'
GROUP BY WMSNAB_MAIN_DESCRIPTION, WNSNAC_DETAIL_DESCRIPTION

1 个答案:

答案 0 :(得分:2)

示例代码

String s = "Adverse EventsAdverse drug reaction 56";
int number = Integer.valueOf(s.substring(s.lastIndexOf(' ')).trim());