Академический Документы
Профессиональный Документы
Культура Документы
hi,
i add a custom view and paste the sql script in sql window pane.
when i click ok i received error message:
thanks
homer.favenir
Top
Make sure you use a SELECT statement only in your Custom View. (Post the SQL of
your Custom View and table schema of the involved tables.)
Webmaster
Posts: 14084
Joined: Fri Aug 06, 2004 5:59 pm
Location: http://www.hkvstore.com/
Top
[code]SELECT
coding_log.`date`,
coding_log.last_name,
`user`.tl,
batch_log.`client`,
batch_log.service,
HOUR(subtime(SEC_TO_TIME(SUM(TIME_TO_SEC(SUBTIME(coding_log.time_en
d,coding_log.time_start)))),
if(min(coding_log.time_start) <= '16:00' and max(coding_log.time_end) >= '16:00',
subtime(max(coding_log.time_end),'16:00'), if(min(coding_log.time_start)
and max(coding_log.time_end) <= '16:00', '0', subtime(max(coding_log.time_end),
min(coding_log.time_start)))))) +
MINUTE(subtime(SEC_TO_TIME(SUM(TIME_TO_SEC(SUBTIME(coding_log.time_
end,coding_log.time_start)))),
if(min(coding_log.time_start) <= '16:00' and max(coding_log.time_end) >= '16:00',
subtime(max(coding_log.time_end),'16:00'), if(min(coding_log.time_start)
and max(coding_log.time_end) <= '16:00', '0', subtime(max(coding_log.time_end),
min(coding_log.time_start))))))/60 as 'Regular Hours',
sum(Hour(IF(coding_log.`Time_End`<coding_log.`Time_Start`,
addtime('24:00:00', timediff(coding_log.`Time_End`, coding_log.`Time_Start`)),
timediff(coding_log.`Time_End`, coding_log.`Time_Start`)))) +
(sum(minute(IF(coding_log.`Time_End`<coding_log.`Time_Start`,
addtime('24:00:00', timediff(coding_log.`Time_End`, coding_log.`Time_Start`)),
timediff(coding_log.`Time_End`, coding_log.`Time_Start`))))/60) as 'Total Man Hours',
"coding_log" as 'Data Process'
FROM
coding_log left join `user` on (`user`.last_name = coding_log.last_name)
inner join batch_log on (batch_log.job_number = coding_log.job_no)
where batch_log.total_batches is not null
group by
coding_log.`date`,
coding_log.last_name,
batch_log.`client`
union
SELECT
key_entry_log.`date`,
key_entry_log.last_name,
`user`.tl,
batch_log.`client`,
batch_log.`service`,
sum(key_entry_log.break_hours) as 'Total Break',
Hour(if (min(key_entry_log.time_start) <= '16:00' and max(key_entry_log.time_end) >=
'16:00',
subtime(max(key_entry_log.time_end),'16:00'), if(min(key_entry_log.time_start)
and max(key_entry_log.time_end) <= '16:00', '0', subtime(max(key_entry_log.time_end),
min(key_entry_log.time_start))))) + minute(if (min(key_entry_log.time_start) <= '16:00'
and max(key_entry_log.time_end) >= '16:00',
subtime(max(key_entry_log.time_end),'16:00'), if(min(key_entry_log.time_start)
and max(key_entry_log.time_end) <= '16:00', '0', subtime(max(key_entry_log.time_end),
min(key_entry_log.time_start)))))/60 as 'Over Time',
HOUR(subtime(SEC_TO_TIME(SUM(TIME_TO_SEC(SUBTIME(key_entry_log.time
_end,key_entry_log.time_start)))),
if(min(key_entry_log.time_start) <= '16:00' and max(key_entry_log.time_end) >=
'16:00',
subtime(max(key_entry_log.time_end),'16:00'), if(min(key_entry_log.time_start)
and max(key_entry_log.time_end) <= '16:00', '0', subtime(max(key_entry_log.time_end),
min(key_entry_log.time_start)))))) +
MINUTE(subtime(SEC_TO_TIME(SUM(TIME_TO_SEC(SUBTIME(key_entry_log.ti
me_end,key_entry_log.time_start)))),
if(min(key_entry_log.time_start) <= '16:00' and max(key_entry_log.time_end) >=
'16:00',
subtime(max(key_entry_log.time_end),'16:00'), if(min(key_entry_log.time_start)
and max(key_entry_log.time_end) <= '16:00', '0', subtime(max(key_entry_log.time_end),
min(key_entry_log.time_start))))))/60 as 'Regular Hours',
sum(Hour(IF(key_entry_log.`Time_End`<key_entry_log.`Time_Start`,
addtime('24:00:00', timediff(key_entry_log.`Time_End`, key_entry_log.`Time_Start`)),
timediff(key_entry_log.`Time_End`, key_entry_log.`Time_Start`)))) +
(sum(minute(IF(key_entry_log.`Time_End`<key_entry_log.`Time_Start`,
addtime('24:00:00', timediff(key_entry_log.`Time_End`, key_entry_log.`Time_Start`)),
timediff(key_entry_log.`Time_End`, key_entry_log.`Time_Start`))))/60) as 'Total Man
Hours',
"key_entry_log" as 'Data Process'
FROM
key_entry_log left join `user` on (`user`.last_name = key_entry_log.last_name)
inner join batch_log on (batch_log.job_number = key_entry_log.job_no)
where batch_log.total_batches is not null
group by
key_entry_log.`date`,
key_entry_log.last_name,
batch_log.`client`
union
SELECT
scan_log.`date`,
scan_log.last_name,
`user`.tl,
batch_log.`client`,
batch_log.`service`,
sum(scan_log.break_hours) as 'Total Break',
Hour(if (min(scan_log.time_start) <= '16:00' and max(scan_log.time_end) >= '16:00',
subtime(max(scan_log.time_end),'16:00'), if(min(scan_log.time_start)
and max(scan_log.time_end) <= '16:00', '0', subtime(max(scan_log.time_end),
min(scan_log.time_start))))) + minute(if (min(scan_log.time_start) <= '16:00' and
max(scan_log.time_end) >= '16:00',
subtime(max(scan_log.time_end),'16:00'), if(min(scan_log.time_start)
and max(scan_log.time_end) <= '16:00', '0', subtime(max(scan_log.time_end),
min(scan_log.time_start)))))/60 as 'Over Time',
HOUR(subtime(SEC_TO_TIME(SUM(TIME_TO_SEC(SUBTIME(scan_log.time_end,s
can_log.time_start)))),
if(min(scan_log.time_start) <= '16:00' and max(scan_log.time_end) >= '16:00',
subtime(max(scan_log.time_end),'16:00'), if(min(scan_log.time_start)
and max(scan_log.time_end) <= '16:00', '0', subtime(max(scan_log.time_end),
min(scan_log.time_start)))))) +
MINUTE(subtime(SEC_TO_TIME(SUM(TIME_TO_SEC(SUBTIME(scan_log.time_en
d,scan_log.time_start)))),
if(min(scan_log.time_start) <= '16:00' and max(scan_log.time_end) >= '16:00',
subtime(max(scan_log.time_end),'16:00'), if(min(scan_log.time_start)
and max(scan_log.time_end) <= '16:00', '0', subtime(max(scan_log.time_end),
min(scan_log.time_start))))))/60 as 'Regular Hours',
sum(Hour(IF(scan_log.`Time_End`<scan_log.`Time_Start`,
addtime('24:00:00', timediff(scan_log.`Time_End`, scan_log.`Time_Start`)),
timediff(scan_log.`Time_End`, scan_log.`Time_Start`)))) +
(sum(minute(IF(scan_log.`Time_End`<scan_log.`Time_Start`,
addtime('24:00:00', timediff(scan_log.`Time_End`, scan_log.`Time_Start`)),
timediff(scan_log.`Time_End`, scan_log.`Time_Start`))))/60) as 'Total Man Hours',
"scan_log" as 'Data Process'
FROM
scan_log left join `user` on (`user`.last_name = scan_log.last_name)
inner join batch_log on (batch_log.job_number = scan_log.job_no)
group by
scan_log.`date`,
scan_log.last_name,
batch_log.`client`
union
SELECT
qc_log.`date`,
qc_log.last_name,
`user`.tl,
batch_log.`client`,
batch_log.`service`,
sum(qc_log.break_hours) as 'Total Break',
Hour(if (min(qc_log.time_start) <= '16:00' and max(qc_log.time_end) >= '16:00',
subtime(max(qc_log.time_end),'16:00'), if(min(qc_log.time_start)
and max(qc_log.time_end) <= '16:00', '0', subtime(max(qc_log.time_end),
min(qc_log.time_start))))) + minute(if (min(qc_log.time_start) <= '16:00' and
max(qc_log.time_end) >= '16:00',
subtime(max(qc_log.time_end),'16:00'), if(min(qc_log.time_start)
and max(qc_log.time_end) <= '16:00', '0', subtime(max(qc_log.time_end),
min(qc_log.time_start)))))/60 as 'Over Time',
HOUR(subtime(SEC_TO_TIME(SUM(TIME_TO_SEC(SUBTIME(qc_log.time_end,qc
_log.time_start)))),
if(min(qc_log.time_start) <= '16:00' and max(qc_log.time_end) >= '16:00',
subtime(max(qc_log.time_end),'16:00'), if(min(qc_log.time_start)
and max(qc_log.time_end) <= '16:00', '0', subtime(max(qc_log.time_end),
min(qc_log.time_start)))))) +
MINUTE(subtime(SEC_TO_TIME(SUM(TIME_TO_SEC(SUBTIME(qc_log.time_end,
qc_log.time_start)))),
if(min(qc_log.time_start) <= '16:00' and max(qc_log.time_end) >= '16:00',
subtime(max(qc_log.time_end),'16:00'), if(min(qc_log.time_start)
and max(qc_log.time_end) <= '16:00', '0', subtime(max(qc_log.time_end),
min(qc_log.time_start))))))/60 as 'Regular Hours',
sum(Hour(IF(qc_log.`Time_End`<qc_log.`Time_Start`,
addtime('24:00:00', timediff(qc_log.`Time_End`, qc_log.`Time_Start`)),
timediff(qc_log.`Time_End`, qc_log.`Time_Start`)))) +
(sum(minute(IF(qc_log.`Time_End`<qc_log.`Time_Start`,
addtime('24:00:00', timediff(qc_log.`Time_End`, qc_log.`Time_Start`)),
timediff(qc_log.`Time_End`, qc_log.`Time_Start`))))/60) as 'Total Man Hours',
"qc_log" as 'Data Process'
FROM
qc_log
left join `user` on (`user`.last_name = qc_log.last_name)
inner join batch_log on (batch_log.job_number = qc_log.job_no)
where batch_log.total_batches is not null
group by
qc_log.`date`,
qc_log.last_name,
batch_log.`client`
order by
`date` desc[/code]
i really need to use the custom view, but it timed out when execution.
thanks!
Guest
Top
1. If you use MySQL 5, you should use view of MySQL instead of Custom View,
especially when the SQL is complicated as yours. As explained in the help file, a Custom
View is basically a SELECT statement, it is not to replace view provided by MySQL 5.
You should always use views provided by MySQL 5 whenever available. Also, since
Custom View only expects a SELECT statement in Custom View, if you use an UNION
statement, it will parse the SQL wrongly, although the script may still work if you don't
use grouping, filter, etc. In this case, you really should use view of MySQL 5.
2. PHP Report Maker only connects for 30 seconds, currently you cannot increase this
setting. If you really have to use Custom View, a workaroud is to modify the SQL and
limit the output so the SQL can be executed by MySQL within 30 seconds, then generate
scripts and change back the SQL in the generated script.
Webmaster
Posts: 14084
Joined: Fri Aug 06, 2004 5:59 pm
Location: http://www.hkvstore.com/
Top
hi,
how can i make union in phpmaker?
thanks
homer.favenir
Top
You shouldn't, for reasons explained above. If you use MySQL 5, always use view in
your database. However, also mentioned above, you still can paste your UNION
statement to create a Custom View anyway, the report may still work properly if you
don't use grouping, filter, etc. Your problem is only that you have too much data and
MySQL cannot execute it in 30 seconds, currently you can only work around as
suggested.