|

楼主 |
发表于 2007-5-11 14:22:25
|
显示全部楼层
在窗体里生存一个数据集,由下面得SQL语句生成后,保存时会报错,而其它得SQL语句不会
SELECT t1.*, t2.*
FROM (SELECT SUM(decode(num, 1, f_inflexion_value, NULL)) "1",
SUM(decode(num, 2, f_inflexion_value, NULL)) "2",
SUM(decode(num, 3, f_inflexion_value, NULL)) "3",
SUM(decode(num, 4, f_inflexion_value, NULL)) "4",
SUM(decode(num, 5, f_inflexion_value, NULL)) "5",
SUM(decode(num, 6, f_inflexion_value, NULL)) "6",
SUM(decode(num, 7, f_inflexion_value, NULL)) "7",
SUM(decode(num, 8, f_inflexion_value, NULL)) "8",
SUM(decode(num, 9, f_inflexion_value, NULL)) "9",
SUM(decode(num, 10, f_inflexion_value, NULL)) "10",
SUM(decode(num, 11, f_inflexion_value, NULL)) "11",
SUM(decode(num, 12, f_inflexion_value, NULL)) "12",
SUM(decode(num, 13, f_inflexion_value, NULL)) "13",
SUM(decode(num, 14, f_inflexion_value, NULL)) "14",
SUM(decode(num, 15, f_inflexion_value, NULL)) "15",
SUM(decode(num, 16, f_inflexion_value, NULL)) "16",
SUM(decode(num, 17, f_inflexion_value, NULL)) "17",
SUM(decode(num, 18, f_inflexion_value, NULL)) "18",
SUM(decode(num, 19, f_inflexion_value, NULL)) "19",
SUM(decode(num, 20, f_inflexion_value, NULL)) "20",
SUM(decode(num, 21, f_inflexion_value, NULL)) "21",
SUM(decode(num, 22, f_inflexion_value, NULL)) "22",
SUM(decode(num, 23, f_inflexion_value, NULL)) "23",
SUM(decode(num, 24, f_inflexion_value, NULL)) "24",
SUM(decode(num, 25, f_inflexion_value, NULL)) "25",
SUM(decode(num, 26, f_inflexion_value, NULL)) "26",
SUM(decode(num, 27, f_inflexion_value, NULL)) "27",
SUM(decode(num, 28, f_inflexion_value, NULL)) "28",
SUM(decode(num, 29, f_inflexion_value, NULL)) "29",
SUM(decode(num, 30, f_inflexion_value, NULL)) "30",
SUM(decode(num, 31, f_inflexion_value, NULL)) "31",
SUM(decode(num, 32, f_inflexion_value, NULL)) "32",
SUM(decode(num, 33, f_inflexion_value, NULL)) "33",
SUM(decode(num, 34, f_inflexion_value, NULL)) "34",
SUM(f_inflexion_value) 合计
FROM (SELECT ROWNUM num,
t1.f_trend_name,
t1.f_inflexion_time,
t1.f_inflexion_value
FROM t_pud_track_trend_zys t1
WHERE t1.f_trend_name = 'TS1_FLUX'
AND t1.f_inflexion_value > 0
AND t1.f_inflexion_time >=
(SELECT MAX(f_inflexion_time)
FROM t_pud_track_trend_zys
WHERE f_trend_name = 'TS1_TOTAL'
AND f_inflexion_time <=
(SELECT MIN(f_inflexion_time)
FROM t_pud_track_trend_zys t1
WHERE t1.f_trend_name = 'TS1_FLUX'
AND t1.f_inflexion_time >=
'2007-04-12 22:11:00'
AND t1.f_inflexion_time <=
'2007-04-12 23:17:00'
AND t1.f_inflexion_value = 0)
AND f_inflexion_value = 0)
AND t1.f_inflexion_time <=
(SELECT MIN(f_inflexion_time)
FROM t_pud_track_trend_zys
WHERE f_trend_name = 'TS1_TOTAL'
AND f_inflexion_time >=
(SELECT MIN(f_inflexion_time)
FROM t_pud_track_trend_zys t1
WHERE t1.f_trend_name = 'TS1_FLUX'
AND t1.f_inflexion_time >=
'2007-04-12 22:11:00'
AND t1.f_inflexion_time <=
'2007-04-12 23:17:00'
AND t1.f_inflexion_value = 0)
AND f_inflexion_value = 0))) t2,
(SELECT t.f_date 日期,
t.f_name 牌号名称,
t.f_opno 批次号,
to_char(to_date(t.f_date || ' ' || t.f_start_h || ':' ||
t.f_start_m || ':00',
'YYYY-MM-DD HH24:MI:SS'),
'YYYY-MM-DD HH24:MI:SS') 批次开始时间,
to_char(to_date(t.f_date || ' ' || t.f_end_h || ':' ||
t.f_end_m || ':00',
'YYYY-MM-DD HH24:MI:SS'),
'YYYY-MM-DD HH24:MI:SS') 批次结束时间
FROM t_z2report t
WHERE f_date = '2007/04/12'
AND f_opno = 86) t1 |
|