gpt4 book ai didi

mysql - 使用 MySQL 作为数据源时 Google Data Studio 出错

转载 作者:行者123 更新时间:2023-11-30 21:35:32 26 4
gpt4 key购买 nike

我在 MySQL 与 Data Studio 的结合中遇到了以下问题,坦率地说,我很迷茫:

SELECT 
user.name,
user.second_name,
school.name,
SUM(booked_lessons.duration),
SUM(total_lessons.duration),
SUM(theory_lessons.duration)
FROM
lesson
LEFT JOIN
user ON lesson.instructor_id = user.id
LEFT JOIN
school ON lesson.school_id = school.id
LEFT JOIN
(SELECT
lesson.id, lesson.duration
FROM
lesson
WHERE
lesson.status = 'active'
AND entity = 'driving'
AND lesson.user_id IS NOT NULL) AS booked_lessons ON booked_lessons.id = lesson.id
LEFT JOIN
(SELECT
lesson.id, lesson.duration
FROM
lesson
WHERE
lesson.status = 'active'
AND entity = ('driving' OR 'theory' OR 'exam')) AS total_lessons ON total_lessons.id = lesson.id
LEFT JOIN
(SELECT
lesson.id, lesson.duration
FROM
lesson
WHERE
lesson.status = 'active'
AND entity = 'theory') AS theory_lessons ON theory_lessons.id = lesson.id
WHERE
lesson.startDate >= '2018-01-31 00:00:00'
AND lesson.startDate <= '2019-01-06 23:59:59'
GROUP BY lesson.instructor_id;`

当我将代码导入为 Google Data Studio 中的 MySQL 数据源时,一开始似乎一切正常。然而,当我想分析图表中的数据时,我确实收到以下错误消息:Error 1

更令人困惑的是:

当我使用这段代码时:

`SELECT 
user.name 'Vorname',
user.second_name 'Nachname',
lesson.instructor_id 'FL ID',
school.name 'Standort',
SUM(offered_lessons.duration) 'noch buchbare Praxisstunden',
SUM(booked_lessons.duration) 'gebuchte Praxisstunden',
SUM(total_week_lessons.duration) 'angebotene Praxis gesamt',
SUM(theory_lessons.duration) 'Theorieunterricht',
SUM(exam_lessons.duration) 'Prüfungen',
SUM(total_lessons.duration) 'angebotene Stunden gesamt',
SUM(activity_lessons.duration) 'Sonstige Tätigkeiten',
SUM(canceled_lessons.duration) 'abgesagt von 123 <48',
SUM(canceled_48_lessons.duration) 'abgesagt von 123 >48',
SUM(canceled_student_lessons.duration) 'abgesagt von Schueler <48',
SUM(canceled_48_student_lessons.duration) 'abgesagt von Schueler >48',
SUM(canceled_instructor_lessons.duration) 'abgesagt von FL <48',
SUM(canceled_48_instructor_lessons.duration) 'abgesagt von FL >48'
FROM
lesson
LEFT JOIN
user ON lesson.instructor_id = user.id
LEFT JOIN
school ON lesson.school_id = school.id
LEFT JOIN
(SELECT
lesson.id, lesson.duration
FROM
lesson
WHERE
lesson.status = 'active'
AND entity = 'driving'
AND lesson.user_id IS NULL) AS offered_lessons ON offered_lessons.id = lesson.id
LEFT JOIN
(SELECT
lesson.id, lesson.duration
FROM
lesson
WHERE
lesson.status = 'active'
AND entity = 'driving'
AND lesson.user_id IS NOT NULL) AS booked_lessons ON booked_lessons.id = lesson.id
LEFT JOIN
(SELECT
lesson.id, lesson.duration
FROM
lesson
WHERE
lesson.status = 'active'
AND entity = 'driving') AS total_week_lessons ON total_week_lessons.id = lesson.id
LEFT JOIN
(SELECT
lesson.id, lesson.duration
FROM
lesson
WHERE
lesson.status = 'active'
AND entity = ('driving' OR 'theory' OR 'exam')) AS total_lessons ON total_lessons.id = lesson.id
LEFT JOIN
(SELECT
lesson.id, lesson.duration
FROM
lesson
WHERE
lesson.status = 'active'
AND entity = 'theory') AS theory_lessons ON theory_lessons.id = lesson.id
LEFT JOIN
(SELECT
lesson.id, lesson.duration
FROM
lesson
WHERE
lesson.status = 'active'
AND entity = 'exam') AS exam_lessons ON exam_lessons.id = lesson.id
LEFT JOIN
(SELECT
lesson.id, lesson.duration
FROM
lesson
WHERE
lesson.status = 'active'
AND entity = 'activity') AS activity_lessons ON activity_lessons.id = lesson.id
LEFT JOIN
(SELECT
lesson.id,
lesson.duration,
TIMESTAMPDIFF(HOUR, lesson.cancelled_at, lesson.startDate)
FROM
lesson
WHERE
lesson.status = 'canceled'
AND entity = 'driving'
AND TIMESTAMPDIFF(HOUR, lesson.cancelled_at, lesson.startDate) < 48
AND user_Id != lesson.cancelled_by_id) AS canceled_lessons ON canceled_lessons.id = lesson.id
LEFT JOIN
(SELECT
lesson.id,
lesson.duration,
TIMESTAMPDIFF(HOUR, lesson.cancelled_at, lesson.startDate)
FROM
lesson
WHERE
lesson.status = 'canceled'
AND entity = 'driving'
AND TIMESTAMPDIFF(HOUR, lesson.cancelled_at, lesson.startDate) >= 48
AND user_Id != lesson.cancelled_by_id) AS canceled_48_lessons ON canceled_48_lessons.id = lesson.id
LEFT JOIN
(SELECT
lesson.id,
lesson.duration,
TIMESTAMPDIFF(HOUR, lesson.cancelled_at, lesson.startDate)
FROM
lesson
WHERE
lesson.status = 'canceled'
AND entity = 'driving'
AND TIMESTAMPDIFF(HOUR, lesson.cancelled_at, lesson.startDate) < 48
AND user_Id = lesson.cancelled_by_id) AS canceled_student_lessons ON canceled_student_lessons.id = lesson.id
LEFT JOIN
(SELECT
lesson.id,
lesson.duration,
TIMESTAMPDIFF(HOUR, lesson.cancelled_at, lesson.startDate)
FROM
lesson
WHERE
lesson.status = 'canceled'
AND entity = 'driving'
AND TIMESTAMPDIFF(HOUR, lesson.cancelled_at, lesson.startDate) >= 48
AND user_Id = lesson.cancelled_by_id) AS canceled_48_student_lessons ON canceled_48_student_lessons.id = lesson.id
LEFT JOIN
(SELECT
lesson.id,
lesson.duration,
TIMESTAMPDIFF(HOUR, lesson.cancelled_at, lesson.startDate)
FROM
lesson
WHERE
lesson.status = 'canceled'
AND entity = 'driving'
AND TIMESTAMPDIFF(HOUR, lesson.cancelled_at, lesson.startDate) < 48
AND instructor_Id = lesson.cancelled_by_id) AS canceled_instructor_lessons ON canceled_instructor_lessons.id = lesson.id
LEFT JOIN
(SELECT
lesson.id,
lesson.duration,
TIMESTAMPDIFF(HOUR, lesson.cancelled_at, lesson.startDate)
FROM
lesson
WHERE
lesson.status = 'canceled'
AND entity = 'driving'
AND TIMESTAMPDIFF(HOUR, lesson.cancelled_at, lesson.startDate) >= 48
AND Instructor_Id = lesson.cancelled_by_id) AS canceled_48_instructor_lessons ON canceled_48_instructor_lessons.id = lesson.id
WHERE
lesson.startDate >= '2018-01-31 00:00:00'
AND lesson.startDate <= '2019-01-06 23:59:59'
GROUP BY lesson.instructor_id;

`代码几乎相同。但现在我收到此错误消息:

Error 2

有人可以帮我吗?

提前致谢。

最佳答案

;
) AS t0 GROUP BY Vorname ORDER BY qt_bdgy5cbbub DESC'

子查询末尾有分号吗,就在

") AS t0"? 

关于mysql - 使用 MySQL 作为数据源时 Google Data Studio 出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54037881/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com