Web应用程序包含两个页面
1.index.jsp 2.result.jsp
索引页面包含输入值,例如weeknum,sla等,用户必须填写输入值,之后查询将在结果页面中执行
这是我的数据库表
weeknum groupby images actct sla24 sla8 CTSUM type
1 studio 123 8.5 5 11 16 16 short
1 studio 12 9.5 6 12 16 12 long
1 studio 154 10.5 7 13 16 short
2 studio 123 11.5 8 14 16 long
2 studio 12 12.5 9 15 16 short
2 studio 154 13.5 10 16 16 long
以下是jsp页面数据库查询(resultPage)
"<sql:query var=""retouch"" dataSource=""jdbc/imaging"">
SELECT WEEKNUM,
GROUPBY,
SUM(IMAGES) AS IMAGES,
SUM(SLA24) AS SLA24,
ROUND(SUM(CTSUM)/SUM(IMAGES),2) AS AVGCT,
ROUND(SUM(SLA24)/SUM(IMAGES)*100,2) AS CTPERC
FROM (SELECT
WEEKNUM,
COLUMNTYPE as groupby,
IMAGES,
ActCT,
IMAGES * AVGCT AS CTSUM,
SLA24,SLA8
FROM RETOUCHSUMMARY
WHERE WEEKNUM = ?
<sql:param value=""${param.weeknum}"" /> )AS CT GROUP BY
WEEKNUM,COLUMNTYPE;
</sql:query>"
上面的查询工作正常,默认情况下它选择sla24列。 有可能,如果用户在索引页面中选择sla8,则查询必须在sla24内选择sla8列。?
希望我解释得很好,请帮忙