I have a Group band with Detail band between the Group header and Group footer. The report is supposed to print multiple student examination records at once. I have grouped them according to the registration numbers. It works except for the fact that query results are shown twice.
as shown
Student 1
Subject score
Maths 50
English 60
kiswahili 70
Maths 50
English 60
kiswahili 70
Student 2
Subject score
Maths 90
English 60
kiswahili 60
Maths 60
English 60
kiswahili 60
insted of
Subject score
Maths 50
English 60
kiswahili 70
Student 2
Subject score
Maths 90
English 60
kiswahili 60
Add an ORDER BY to the end of your query:
ORDER BY registration_number, subject
Your data should be sent to the report template in the order in which it will be displayed. Order by student and then by subject.
Related
A test with 20 questions was applied to 300 people. We know that 8 questions had at least
100 hits and the rest at least 200 hits. Prove that some student got at least 11 questions right.
OK assume exactly 8 questions got 100 hits and the remaining 12 got exactly 200 hits. That means there were exactly 8 * 100 + 12 * 200 = 800 + 2400 = 3200 hits. If no student had at least 11 questions right, then the most any student could have got right is 10. If 300 students each got 10 answers right, that's just 3000 hits. But we know there were at least 3200 hits. Therefore, it can't be that there's no student with at least 11 hits; some student must have at least that many.
I have a table like this:
2019.03m Bolts 100
2019.03m Nuts 50
2019.02m Bolts 10
2019.02m Nuts 100
2019.01m Bolts 50
2019.01m Nuts 10
2018.12m Bolts 10
2018.12m Nuts 10
2018.11m Bolts 20
2018.11m Nuts 30
I would like to introduce a new column called the year to date column
2019.03m Bolts 100 160
2019.03m Nuts 50 160
2019.02m Bolts 10 60
2019.02m Nuts 100 110
2019.01m Bolts 50 50
2019.01m Nuts 10 10
2018.12m Bolts 10 30
2018.12m Nuts 10 40
2018.11m Bolts 20 20
2018.11m Nuts 30 30
This sums the previous year-to-date row and resets when it reaches a new year.
I have an idea of using sums but how can I reset when I get to a new year?
I believe the below is what you are after. Note I have reversed the table in order put in time ascending order initially.
reverse update YTD:sums Number by tool,date.year from reverse t
date tool Number YTD
------------------------
2019.03 Bolts 100 160
2019.03 Nuts 50 160
2019.02 Bolts 10 60
2019.02 Nuts 100 110
2019.01 Bolts 50 50
2019.01 Nuts 10 10
2018.12 Bolts 10 30
2018.12 Nuts 10 40
2018.11 Bolts 20 20
2018.11 Nuts 30 30
If your table is ordered by date(descending in your example) you can use below query. Else you can just order it using date xdesc before running the query.
q) update ytd:reverse sums reverse num by date.year,name from t
I have input data like below
CovNo type Price
10 med tot 110
10 med tot 120
10 dent tot 140
20 med tot 110
20 dent tot 130
20 med tot 120
How can i generate the output data like below
CovNo type Price
10 med tot 110
10 med tot 120
10 dent tot 140
10 Group tot 370
20 med tot 110
20 dent tot 130
20 med tot 120
20 Group tot 360
Shall i know the logic to implement the above scenario in Datastage.
Thanks in advance,
Shanmugam
Depending on the source of your data one way could be to solve it with SQL if your source is a table.
If you want or need to do it in DataStage only you could fork your data using a copy stage and have one output fed into an aggregtor stage where you calculate the sums per group. The other output is of the copy is then combined with the results of the aggregator with a funnel stage (which behaves like a union in SQL). That's it.
For the above example, we could achieve it in transformer using the SaveInputRecord() and GetSavedInputRecord() and LastRowInGroup() functions.
IBM has provided a perfect example for this type of scenario.
Note: The performance would be impacted if the data is huge as it uses cache memory. So if your data is huge, then better to split the source and perform a join after the aggregation or you could easily do it using sql if you source is a database.
I created the below view that gives No. of students got PASS/FAIL in each subject . The tool Tip gives me some default options.
But I would like to have Percentage in tool tip
Basically I need Percentage field in tooltip that says 50% for below screen.
PASS Percentage 50%
FAIL Percentage 50%
This Percentage field needs to vary as per each subject and its grade among students
Could somebody help me on steps to include Percentage in Tooltip?
sample dataset
id name age gender subject grade
100 Steve 14 MALE ENGLISH PASS
100 Steve 14 MALE PHYSICS PASS
100 Steve 14 MALE CHEMISTRY PASS
101 Edward 15 MALE ENGLISH FAIL
101 Edward 15 MALE PHYSICS FAIL
101 Edward 15 MALE CHEMISTRY FAIL
102 Andy 15 FEMALE ENGLISH PASS
102 Andy 15 FEMALE PHYSICS PASS
102 Andy 15 FEMALE CHEMISTRY FAIL
103 Kim 16 FEMALE ENGLISH FAIL
103 Kim 16 FEMALE PHYSICS FAIL
103 Kim 16 FEMALE CHEMISTRY PASS
Table calcs let you calculate percent of totals without creating new calculated fields.
Put SUM(Number of Records) on the Tooltip shelf. Then click on it and choose Quick Table Calc->Percent of Total. You will see a triangle icon next to the field indicating it is now a table calculation
Experiment with changing the Compute Using setting for the Field. I believe compute using Grade is probably the one you want.
I did this with a few calcs. First, get the PASS count.
if [Grade] = 'PASS' then 1 END
Then create a Pass % calc.
sum([Pass count]) / total(countd([Id]))
Now you can place this field in the Tooltip. Repeat for FAIL as well and place that in the Tooltip.
Then I updated the tooltip as follows:
Number of students <CNTD(Id)> (<AGG(pass %)> <AGG(fail %)>) who got a <Grade> in <Subject>
see sample workbook here for details. https://dl.dropboxusercontent.com/u/60455118/160326%20stack%20question.twbx
I have a table like this and I need average of each subjects of all students(here 2 only)
Student Subject Marks
John Maths 80
John Science 70
John Social 90
Raju Maths 90
Raju Science 80
Raju Social 70
o/p should like this
Subject Average
Maths 85
Science 75
Social 80
You may use below query:
select studentInfo.Subject, avg(studentInfo.marks) from studentInfo group by studentInfo.Subject
Please refer below link:
enter link description here