0
我在attandance日期,但其显示的2017年最新的日期,只是2016日期好心plz帮助我需要最后日期从提到的查询获取以下
SELECT
added_on,
types. `type`,
student.`student_id`, student.`roll`, student.`class_id`, student.`name` AS student_name,
SUM(datewise_attandance.`total_classes`) AS SumOfTotal,
datewise_attandance.attandance_date AS attandance_date,
SUM(datewise_attandance.`status`) AS SumOfPresent,
#ROUND(((SUM(datewise_attandance.`status`)/SUM(datewise_attandance.`total_classes`))*100),2) AS percentage,
class.`name` AS class_name, student.`sex`, student.`father_name`, student.`address`,
student.`phone`, subject.`name` AS subject_name,
#types.`type`, types.`type_id`,
subject.`subject_id`,
#MAX(datewise_attandance.`date_to`) AS MaxOfAtt_Date_To,
student.`session_id`
FROM
((class
INNER JOIN `subject` ON class.`class_id` = subject.`class_id`)
INNER JOIN datewise_attandance # (INNER JOIN types ON datewise_attandance.`type_id` = types.`type_id`)
ON (subject.`subject_id` = datewise_attandance.`subject_id`)
AND (class.`class_id` = datewise_attandance.`class_id`))
INNER JOIN `types` ON(types.`type_id` = subject.`subject_type`)
INNER JOIN student ON (student.`student_id` = datewise_attandance.`std_id`)
AND (class.`class_id` = student.`class_id`)
GROUP BY student.`student_id`,
student.`roll`, student.`class_id`, student.`name`, class.`name`,
student.`sex`, student.`father_name`, student.`address`,
student.`phone`, subject.`name`,
# types.`type`, types.`type_id`,
subject.`subject_id`, student.`session_id`
HAVING (
(
student.`class_id` = 4
AND student.`roll` = 388
AND student.`session_id` = 5
)
) ORDER BY IFNULL(subject.final_exam,0) DESC
此SQL查询是卷积的方式。你确定你需要这么多的内部连接(x6)?! 与其试图解决这个问题,我最好的建议是重新设计解决方案并找到更简单的路径,以上是意大利面条。 – Cyril