How to calculate number in Group of an SSRS report? - reporting-services

In one of report that I need to develop using FetchXMl, I've to show number of male and female students that are studying a certain course. My goal is to show the reports as following:
Course Name Male Female
Physics xx xx
Chemistry xx xx
Computer Science xx xx
But I am getting
Course Name Male Female
Physics xx
xx
xx
Chemistry xx
xx
xx
xx
Computer Sciences xx
xx
xx
xx
Any idea how to get specified format for this report?

Given a data table students:
id course gender
1 Math m
2 Math f
3 Physics f
4 Sports m
5 Sports f
6 Sports f
You need a matrix (tablix) with a row group that groups by Course Name and a column group that groups by Gender. In the tablix body you add a count expression to show the number of students per course.
design view
result preview

Related

How can I do count on number of occurrences of each distinct value of a column in PostgreSQL?

List of students enrolled in courses. In each course there could be x homeworks.
I need count of homeworks for each course for each student.
Eg:
Sample table
Mark Math hw1
David. Math hw2
Mark. Science. hw1
Mark Math. hw2
David. Science. hw1
David. Literature. hw1
Expected results (3 columns)
Mark | Math | 2 (because two math homeworks)
Mark | Science | 1 home work
David| Math | 1 home work
David| Science | 1 home work
David| Lit. | 1 home work
select name, course, count(*)
from your_table
group by name, course

Finding the Max of multiple score assigned to a student ID number

I am currently a teacher and I have a database containing hundreds of students. That database has student ID numbers, student names, and scale scores for reading and math tests as shown below. I want column F to display the student's highest score and column G to display when student tested recently. I want these columns to display these data by linking them through their ID numbers. I could do that if the ID numbers were not repeated but having the same ID numbers being repeated multiple times is causing me problems.
column A column B column C column D column E column F column G
ID number last name First name Math score test date Highest score Most recent test date
1705555 Smith Joe 543 9/1/19 ? ?
1706666 Solis Juan 459 10/8/19
1773333 Jackson Devonte 654 10/14/19
1772222 Villa Maria 329 9/4/19
1778888 Bilal Issa 600 10/21/19
1705555 Smith Joe 410 8/11/19
1706666 Solis Juan 389 7/25/19
1773333 Jackson Devonte 500 8/24/19
1705555 Smith Joe 510 6/30/19

MS Access - Count of multiple values

I have a this Table in MS Access:
Table1
ID EMP ROLE ASSESS
1 JOE Weld 4
2 TOM Weld 4
3 JIM Ship 4
4 PAT Ship 3
5 JAY Weld 4
6 TIM Ship 4
"ROLE" is short text and "ASSESS" is a number field. "ASSESS" is assessing employees' roles on a scale of 1-4. I want to collect and total assessments that are "4" for each role.
Returning something like:
ROLE TOTAL
Weld 3
Ship 2
I however have around 100 different roles that I am needing to do this with. Is there a way with SQL or a combination of query and macro to make this work? I am at a loss.
Thank you.
You could use a where clause to filter just the the assesses that are 4 and a group by clause to aggregate them:
SELECT role, COUNT(*)
FROM table
WHERE assess = 4
GROUP BY role

Which kind of join should i use? [EF4.0 code first ]

i apologize for the bad topic title as i am kinda at lost of what should i do here.
First of all, here are my database table designs and i would like to receive some sort of feedback as well before proceeding:
I am trying to make an enrollment web application.
Subjects
subject
[id] [subj] [professor] [cstart] [cend] [days] [count] [units]
1 comalgo carl 10:00am 12:30pm M-W 40 3.0
2 compasm carl 01:00pm 02:30pm T-TH 40 3.0
3 compro miguel 04:30pm 06:30pm M-W 35 3.0
4 pro5 fua 03:30pm 05:30pm T-TH 30 3.0
5 pro5 fua 06:30pm 08:30pm F 10 3.0
Students
students
[id] [fname] [lname] [bday] [unitsleft] [unitstaken] [major]
1 carlos doe 11/20/1990 100 0 BS-COMPUTER SCIENCE
2 miguel doe 08/15/1992 100 0 BS-ECONOMY
3 carl doe 12/12/1991 100 0 BS-PSYCHOLOGY
4 test doe 02/12/1992 100 0 BS-LITERATURE
What i plan on doing is that, the subjects will be presented through a series of list and the student will pick multiple subjects and enroll. The total enrolled units should not be greater than 20 and less than 11. I already implemented that part and i am now working on storing the selected subjects.
Here is my proposed solution and i would like to receive some feedbacks about it and what operation should i use.
I will have a centralized table for all of enrolled subjects
Enrolled subjects
selected subject
[id] [subjid] [studentid] [status]
1 1 1 P //comalgo enrolled by carlos, P is for pending grade
2 1 2 P //comalgo enrolled by miguel P is for pending grade
3 2 1 P //compasm enrolled by carlos P is for pending grade
What i plan to happen is that: i have a profile page for the students and they will be able to view/edit their currently enrolled subjects specifically for themselves(based from ID)
I want them to be presented with the following table headers which is based from the enrolled subjects:
[subj] [professor] [cstart] [cend] [days]
Here are the brief summary of my questions:
1.) is my table alright? or it's a bad design?
2.) What kind of method should i use? i am trying to research about it(joins) but i am somehow confused and in need of clarification. I want to present the users with their selected subjects.
edit: i think i can do something like.. select where id = x from the enrolled subjects then get the subject id but i am not sure if that will be efficient.
Your tables look good (i.e. third normal form). An INNER join will do
SELECT
B.subj, B.professor, B.cstart, B.cend, B.days
FROM
selectedsubjects A
INNER JOIN subjects B ON A.subjid = B.id
WHERE
A.studentid = 1
p.s. This looks like an assignment for school or something out of a book...?
It could be:
var query = context.EnrolledSubjects
.Include("Subject")
.Where(i => i.StudentId == 1)
.Select(i => new {
i.Subject.Subj,
i.Subject.Professor,
i.Subject.CsStart,
i.Subject.Send,
i.Subject.Days,
i.Status
};

Add the columns automatically in SSRS report

Currently we are having 6 columns in our database table which we are showing in the SSRS report but in future if we add 1 more column then without any manual changes on RDL it will included in the report.
Current report Example :-
Name Address Code City County Country
xyz Lane 1 466001 Bang dbc Africa
abc Lane 2 466002 Bpl bbn Nepal
dcb Lane 3 466003 sbc wad Bhutan
Expected report without adding the column manually in SSRS.
Name Address Code City County Country DOB
xyz Lane 1 466001 Bang dbc Africa 19/06/1986
abc Lane 2 466002 Bpl bbn Nepal 20/06/1990
dcb Lane 3 466003 sbc wad Bhutan 21/8/2000
Thanks for any help.
Please follow below steps..
Step 1. Create Proc using UNPIVOT and Property(ColunName) & Value with ID column (PKey) like
SELECT Pkey,tblPivot.Property, tblPivot.Value
FROM (SELECT EmpNo AS Pkey, CONVERT(sql_variant,EmpNo) AS EmpNo, CONVERT(sql_variant,EName) AS EName, CONVERT(sql_variant,JOB) AS JOB,
CONVERT(sql_variant,Sal) AS Sal FROM EMP) EMP
UNPIVOT (Value For Property In (EmpNo,EName, JOB, Sal)) as tblPivot
Step 2.
Create a Matrix Report using above SP with row-grouping on [Pkey] and col-grouping on [Property] and Display value ...
Step 3 Now you can add/remove column in SP (step 1) based on your requirement