Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Multiple values in a row
LizBPRD
<span style='font-family: Verdana'>Hi,<br />
<br />
I'm still fumbling my way around e.Report Designer 8 SP1 (due to upgrade to 10 in a month or two) and am trying the following...<br />
<br />
I want a report that displays each client's details in a row like this (I've also listed the columns that are to appear):</span><br />
<br />
<span style='font-family: Courier New'><span style='color: #FF0000'>ID</span> | <span style='color: #FF8C00'>Name</span> | <span style='color: #2E8B57'>Activity</span> | <span style='color: #008080'>Plan</span><br />
<br />
<span style='color: #FF0000'>ASH_SUBJECT_ID</span> | <span style='color: #FF8C00'>ASH_SUBJECT_NAME</span> | <span style='color: #2E8B57'>AV_QUE_VALUE</span> | <span style='color: #008080'>AV_QUE_VALUE</span></span><br />
<br />
<span style='font-family: Verdana'>The SQL currently looks like this (it includes other things I want to report on, but aren't relevant to this post):</span><br />
<br />
<p class='bbc_indent' style='margin-left: 40px;'><span style='font-family: Courier New'>SELECT ash_assessment_type, ash_subject_id, ash_subject_name, ash_team_name, asm_completed_by, asm_complete_datetime, av_que_value, per_id, per_first_names||' ' ||per_surname<br />
<br />
FROM o_assessment_header, o_assessments, o_avd_reporting_view, o_persons<br />
<br />
WHERE o_assessment_header.ash_asm_id = o_avd_reporting_view.av_asm_id<br />
<br />
AND o_assessment_header.ash_asm_id = o_assessments.asm_id<br />
AND o_assessments.asm_completed_by = o_persons.per_id<br />
AND (av_qst_id = '<span style='color: #2E8B57'>J8526</span>' OR av_qst_id = '<span style='color: #008080'>J8533</span>')<br />
AND av_que_value IS NOT NULL<br />
AND asm_complete_datetime IS NOT NULL</span></p>
<br />
<span style='font-family: Verdana'>How can I get the report to show the <span style='color: #2E8B57'>AV_QUE_VALUE</span> of <span style='color: #2E8B57'>J8526</span> under Activity, and the <span style='color: #008080'>AV_QUE_VALUE</span> of <span style='color: #008080'>J8532</span> under Plan? I was hoping something simple in the MyQuery or the expression builder could cope.<br />
<br />
Apologies if this is the wrong forum, or my question unbelievably simple.</span>
Find more posts tagged with
Comments
Hans_vd
Hi LizBPRD,<br />
<br />
You have to select from the table that contains the column av_qst_id twice.<br />
So you add that same table to the from line a second time (use aliases), then join it to all the other tables and use one alias in the where clause to select 'J8526' and one alias to select 'J8533'.<br />
<br />
As I don't know your datamodel, here's a quick dummy example:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>SELECT dt1.select_field, dt2.select_field
FROM dummy_header dh, dummy_tab dt1, dummy_tab dt2
WHERE dh.join_field = dt1.join_field
AND dh.join_filed = dt2.join_field
AND dt1.av_qst_id = 'J8526'
AND dt2.av_qst_id = 'J8533'</pre>
<br />
Hope this helps<br />
Hans
hcy1986
Or like this:
[sql]SELECT ash_assessment_type, ash_subject_id, ash_subject_name, ash_team_name, asm_completed_by, asm_complete_datetime,
case when av_qst_id = 'J8526' then av_que_value end as Activity,
case when av_qst_id = 'J8533' then av_que_value end as Plan,
per_id, per_first_names||' ' ||per_surname
FROM o_assessment_header, o_assessments, o_avd_reporting_view, o_persons
WHERE o_assessment_header.ash_asm_id = o_avd_reporting_view.av_asm_id
AND o_assessment_header.ash_asm_id = o_assessments.asm_id
AND o_assessments.asm_completed_by = o_persons.per_id
AND (av_qst_id = 'J8526' OR av_qst_id = 'J8533')
AND av_que_value IS NOT NULL
AND asm_complete_datetime IS NOT NULL[/sql]
Hans_vd
hcy1986,
Your query will not give the desired result unless you add a GROUP BY clause.
Regards
Hans
LizBPRD
Thanks everyone, my report finally works! Now people will no doubt be asking for more reports.