I have a question: I have a table with a simple selector that filtered the table by user. at this moment I want the selector to be multiple in order to filter the data by several users. by default I put the user ' Todos' (all in english), in case of choosing the user ' Todos' I choose the column of the table to select all users. Otherwise I take the selected user.
SELECT DISTINCT
p.pname AS project,
SUM(w.timeworked / 3600) OVER () AS sum_all_hours,
SUM(w.timeworked / 3600) OVER (PARTITION BY p.pname) AS suma_proyecto
FROM
jira.jiraissue j,
jira.worklog w,
jira.project p
WHERE
w.issueid = j.id
AND j.project = p.id
AND w.author IN (${Autor})
AND p.pname IN ('Area Económica',
'Proyectos Clinicos',
'Proyectos. Con sus componentes',
'Despliege y Soporte')
AND TO_CHAR(w.startdate,'yyyy-mm-dd') >= ${FromDate}
AND TO_CHAR(w.startdate,'yyyy-mm-dd') <= ${ToDate}
This code works fine but omits the user ' Todos'.
If I put the following code, the user works ' Todos' and if I select a single user but the multiple selection does not show me anything.
SELECT DISTINCT p.pname AS project,
Sum(w.timeworked / 3600) OVER () AS sum_all_hours,
Sum(w.timeworked / 3600) OVER (partition BY p.pname) AS suma_proyecto
FROM jira.jiraissue j,
jira.worklog w,
jira.project p
WHERE w.issueid=j.id
AND j.project=p.id
AND w.author in(
CASE
WHEN ${Autor} = ' Todos' THEN author
else ${Autor}
END)
AND p.pname IN ('Area Económica',
'Proyectos Clinicos',
'Proyectos. Con sus componentes',
'Despliege y Soporte')
AND to_char(w.startdate,'yyyy-mm-dd') >=${FromDate}
AND to_char(w.startdate,'yyyy-mm-dd') <=${ToDate}
JOINsyntax in the ANSI-92 SQL Standard (25 years ago) and its use is discouraged - marc_s