下面列出的代码当前填充下拉列表,如
所有运动
运动 - 棒球
运动 - 保龄球
运动 - 篮球
这真的是
Logtypid=3935 - subtypeid=x
我需要子类型 id 来提取 2 个额外的子类型,它们的 logtypeid 不为 3935,但问题是这些子类型的 logtypeid 为 626。我只需要 logtypeid 为 3935 的学生。目前..我写的方式:
SELECT DISTINCT log.logtypeid,
CASE WHEN log.subtype is null THEN ' ' ELSE log.subtype END subID,
CASE WHEN ','||'~[gpv:lt]'||',' LIKE '%,' || log.subtype || '.' || CASE WHEN log.subtype is null THEN ' ' ELSE log.subtype END || ',%' THEN 'selected' ELSE '' END isselected,
lt.Name logtype,
CASE WHEN to_char(st.ValueT) is null THEN ' - NONE' ELSE ' - ' || to_char(st.ValueT) END subtype
FROM log
INNER JOIN gen lt ON log.logtypeid = lt.id
LEFT OUTER JOIN gen st ON st.Name = to_char(lt.ID)
AND st.value = log.subtype
AND st.Cat = 'subtype'
WHERE lt.Cat = 'logtype'
AND logtypeid = '3935'
AND to_char(log.schoolid) like CASE WHEN ~(curschoolid) = 0 THEN '%' ELSE to_char(~(curschoolid)) END
ORDER BY subtype
;]
我已经尝试了一切,我开始认为也许为了获得所需的结果,我可能需要为它创建一个表。任何帮助或想法将不胜感激。谢谢。
Data Example:
STUDENTID LOGTYPEID SUBTYPE
6382 626 27
6382 626 41
6382 626 38
6382 626 43
6382 626 29
6382 3935 109
6382 3935 117
6383 626 43
6383 626 30
6383 626 43
6383 626 25
6383 626 43
6383 626 14
6383 3935 117
6400 626 38
6401 626 28
6401 626 36
6401 3935 110
该代码使用 tlist 填充用于运行报告的下拉列表的选择选项。选择选项名称来自 GEN 表,它应该解释连接。运动日志是 3935,健康日志是 626。我们只想在下拉列表中显示运动日志。When Sports - Baseball is selected, and the report is run, the output should be only students who have logtype 3935 and subtype x(whichever subtype is baseball), but the output needs to also pull the same students logtypeid 626, specifically only subtype 29和 43. 这有意义吗?