sqlReports is an ad hoc reporting add-on that can turn simple to medium sql queries in to web based reports in PowerSchool. Essentially, you would create a sql query in your favorite query tool then copy and paste the query in to sqlReports. sqlReports will help convert the query from multiple columns of raw data to just sql one column with data separated by table cell tags (the tds and /tds). You also can use up to 5 different parameters to make the reporting more flexible.
NOTICE: This is a PowerSchool 6.x only customization...though I am not opposed to someone hacking it to work with 5.x. But c'mon, who wants to work in 5.x?
disclaimer: It works because variable columns of data that are needed for tlist_sql are converted in to just one column with the data concatenated in to an html/table cell format.
Here is a video to get you started:
http://www.rschooltoday.com/school608/genie198/images/files/howtocreatea...
Comments
Love this tool
I have a question about using things like per.att in this tool. I read somewhere that it would work if it is put inside single quotes. I have tried that but I don't get a valid count. I am using the example you posted that lists the students courses and am trying to list absences instead. The currentabsences in the cc record does not seem to be accurate.
any ideas???
thanks!
Max B
Attendance in a query
Max, I am not sure about the per.att inside a sql query. I don't know if I would trust the results. My guess is that you will need to make a subquery of one of the attendance views to see the totals you are looking for. And, you are right, the info in the CC table was legacy information to my knowledge and is not functioning anymore...I think.
Thanks.
Dean.
thanks for your reply
Thanks, Dean, I did in fact write a query from a view and got it working but when I moved it to sql reports it doesn't work. I used the COUNT() AS to count records with an A code and it matches the data from the quick lookup.
Is the COUNT command messing me up?
Max B
Data Applications Specialist
Colonial Beach, VA
Re: thanks for your reply
Don't use AS, this is called aliasing and won't work with sql reports. So if I have "count(a.id) as something" just use "count(a.id)" in sql reports.
took out the AS
I took out the AS and it works great in sql developer but still not in sql reports. Here is my code.
SELECT DISTINCT(s.lastfirst), s.student_number, psa.period_number, COUNT(PSA.att_code)
FROM PS_ATTENDANCE_MEETING PSA
INNER JOIN Students s
on s.ID = PSA.StudentID
WHERE PSA.STUDENTID = S.ID AND PSA.ATT_CODE = 'A' AND psa.att_date > '07-SEP-09'
GROUP BY s.lastfirst, s.student_number, psa.period_number ORDER BY s.lastfirst
Max B
Data Applications Specialist
Colonial Beach, VA
DISTINCT is stinking up the works
Max, I think the DISTINCT is causing the problem. I ran your query on my server and got the same results (number of records) with the DISTINCT and without it. I am wondering if you can remove it and then re-tag your sqlReport.
My guess is that when you try to include the DISTINCT in a concatenated string it fouls up the works. This might be a bug down the road...but in your case, I think you can do without it...maybe =)
Good luck!
Dean.
Thanks for all of your help,
Thanks for all of your help, but believe it or not it still will not run. I have 12 other sql reports that work but this one doesn't seem to like me. I will keep working on it because I'm anal like that!
thanks again and I still love this tool!
Max B
Data Applications Specialist
Colonial Beach, VA
Re: Thanks for all of your help,
Try this;
SELECT DISTINCT '
'
FROM PS_ATTENDANCE_MEETING PSA
INNER JOIN Students s
on s.ID = PSA.StudentID
WHERE PSA.STUDENTID = S.ID AND PSA.ATT_CODE = 'A' AND psa.att_date > to_date('07-SEP-09', 'DD-MMM-YY')
GROUP BY s.lastfirst, s.student_number, psa.period_number ORDER BY s.lastfirst
Can you use the parameter feature for date range
I would like to be able to use the %param% to let the end user specify a date range. Specifically so they can pull discipline reports by an incident date range. Is there a way to do this using the %param% feature?
Thanks, Dean...this has already been a huge help in writing reports.
Date Ranges and Parameters
Jane, I will post a quick screen shot of how I would use the %param% feature in a date range. The trick is to remember the to_date function =)
You should see it listed above as sqlReportsDateRangeExample.jpg
Thanks!
Dean.
Date Ranges
Dean,
THANK YOU!!!! I am going to be sooo productive and my schools are going to be sooo happy!
I'm just a little excited!!!
Thanks,
Jane
Hi, I have just downloaded
Hi, I have just downloaded sqlReports and test with the query below (this query get the average for stored grades and pivot it to better display). However I always have a Records nor found message. The query works fine in SQLDeveloper. Any ideas will be much appreciated.
select course_name, max(decode(storecode,'P1',Promedio,Null)) AvgP1,
max(decode(storecode,'E1',Promedio,Null)) AvgE1,
max(decode(storecode,'S1',Promedio,Null)) AvgS1
from(
SELECT course_name,storecode,cast(avg(percent)as decimal (20,2)) Promedio
FROM STOREDGRADES
where (storecode='P1' or storecode='E1' or storecode='S1')
and schoolid='1234'
and termid='1901'
GROUP BY course_name, storecode
order by course_name
)
group by course_name
This has tricked me in the
This has tricked me in the past too. My tool doesn't handle aliasing very well. I your query you have:
select course_name, max(decode(storecode,'P1',Promedio,Null)) AvgP1,
max(decode(storecode,'E1',Promedio,Null)) AvgE1,
max(decode(storecode,'S1',Promedio,Null)) AvgS1
...
change this to:
select course_name, max(decode(storecode,'P1',Promedio,Null)),
max(decode(storecode,'E1',Promedio,Null)),
max(decode(storecode,'S1',Promedio,Null))
essentially you are removing the AvgP1, AvgE1 and AvgS1 aliases...these can go in the header area of sqlReports.
Good luck!
Dean.
Thanks again...
Dean,
Thanks again for your suggestions. This worked great! My SQL is quite rough, but this accomplishes in seconds what was taking days with a pivot table!
Thank you!!!!
Jim
Samples???
Does anyone happen to have any examples that might help to export a "student schedule" one line that contains student demographic information and Period 1-8 schedule information. Have tried using an ODBC connection and pivot table, but takes forever to process. This seems like it would work great, but need some samples to get me going. Any other ideas would be helpful.
Thanks!
Samples???
Jim, would this get you started?
SELECT
q.studentid,
s.lastfirst,
MAX(CASE WHEN p# = 1 THEN q.course_name
ELSE NULL END),
MAX(CASE WHEN p# = 2 THEN q.course_name
ELSE NULL END),
MAX(CASE WHEN p# = 3 THEN q.course_name
ELSE NULL END),
MAX(CASE WHEN p# = 4 THEN q.course_name
ELSE NULL END),
MAX(CASE WHEN p# = 5 THEN q.course_name
ELSE NULL END),
MAX(CASE WHEN p# = 6 THEN q.course_name
ELSE NULL END),
MAX(CASE WHEN p# = 7 THEN q.course_name
ELSE NULL END),
MAX(CASE WHEN p# = 8 THEN q.course_name
ELSE NULL END)
FROM
(SELECT cc.studentid, cc.id, cc.expression, c.course_name, rank() OVER
( PARTITION BY cc.studentid ORDER BY cc.expression ) as p#
FROM cc cc, courses c
WHERE c.course_number=cc.course_number
and cc.termid in (1900,1901,1903,1904)
and cc.schoolid=1
and cc.sectionid>0) q, students s
WHERE s.id=q.studentid
GROUP BY q.studentid, s.lastfirst ORDER by q.studentid
This is the native sql that I got to work in sqlReports. You would need to watch the termid/schoolid, etc for your environment.
Samples
If I needed to add the course number to the course name as well as additional student information - is that possible? I have been working on it, unsuccessfully (so far), but I thought I would see if was even possible before I put much more time into it.
Thanks again.
student and course additions
Yes, you should be able to add student fields like normal since the Students table is "linked". As for course_number, I think I would concatenate this with the course_name in the embedded select statement. Course number is tricky since it is another field dependent on the period...that is why I think I would put course_number and course_name in to one field in the embedded select. I think it makes it easier for the MAX CASE statements. I am definitely not an SQL pro. There might be someone out there with better solution!
Dean.
Another sample...
Dean,
This is great - I have been able to use this for many reports... Do you have any samples that would also pull data from fields on a custom student screen?
Thanks,
Jim Ohlensehlen
Samples
This is PERFECT!!!! Thanks for your help!!!
Awesome customization! Thank you!
This is a fantastic tool for adding custom reports easily into PowerSchool. Using the basic SQL skills I learned at the Michigan System Administrator's Conference, I have used this add on to create several custom reports including data validation reports for Michigan Pupil Accounting (state reports).
The video link was a perfect intro to get me started. Thanks for posting it!
Laurie Kinney
Thanks Laurie! I originally
Thanks Laurie! I originally created this to help with my own state reports. I would like to use a line or two of Brian Andle code to provide an option to see certain queries in a dashboard format. I know this would help my data validation for Minnesota.
Happy Holidays!
Dean.
Sql Query Text Box character limit?
Is there a character limit to what can be entered into the SQL Query Text Box?
Also is there a way I can create an exported report file for import?
Robert Wadsworth
Robert, I want to venture a
Robert, I want to venture a guess of 32k for the text box size. I have not run in to a limitation yet.
Also, you can export a report to be imported later. There might be a "gotcha" if you are using any of the PowerSchool data tags like ~(curschoolid) or something like that. These might populate with real data instead of keeping the ~(curschoolid) format. To export a report, just edit it and choose the export option at the bottom of the edit page.
I hope you can find some use for sqlReports. It has worked well for me.
Dean.
~(curschoolid) has got me
I'm having trouble as you stated above with the ~(curschoolid) storing actual data. It then won't allow the report to show up at other schools once one school has run it. Have you got a workaround? It was running fine before I imported the custom Reports bundle. Once I imported it all of my sql reports disappeared so I had to import them from my test database.
I LOVE this package but if I can't get it to work using ~(curschoolid) or other internal PS commands I'll be REALLY disappointed. I've become an expert at the quick little sql report!
Jill Anderson
Data Analyst/Lead Report Writer
Park Hill School District
Kansas City, MO
latest version
Jill, I think this was an issue in the first release of sqlReports. Be sure to check the version info of sqlReports at the bottom of the help page. You should be running on v1.1.
Thanks!
Dean.
~(curschoolid) still causing issues
Dean,
I am on the latest version yet when I create a SQL report it shows for all schools. Once I go into a school and run it, the report then disappears from the other schools. I am on running 1.1. Please help.
Kevin
sqlReports for 6.x version 1.10
I have uploaded a new version of sqlReports (v1.10). Not much has changed but I did clean up a few things. I also added a report that can be imported as a sample. This report will basically show you a run history of all of your created sqlReports. So, down the road, if you are wondering "Does the principal really use this report?", you can execute the Run History and find out.
And let's see if this works. Here is a link to a video to help get you started with sqlReports:
http://www.proctor.k12.mn.us/infotech/swf/HowToCreateAsqlReport.swf
Update SQL statement?
Can this be used to issue update SQL statements?
Re: Update SQL statement?
No it can not, also attempting/using SQL write access is a violation of your license and support contract. If Pearson was to find out you found a way to issue these types of statements, they have the right to cancel your support contract and stop supporting you.
Brian Andle
SQL to display web gradebook final grade setups
SELECT '
T.FirstName||'
SC.Description||'
S.SectionIdentifier||'
FGS.FinalGradeSetupType||'
P.Q1||'
P.Q2||'
P.Q3||'
P.Q4||'
P.E1||'
P.E2||'
P.R1||'
P.R2
||'
'
FROM PSM_FinalGradeSetup FGS
INNER JOIN
psm_Section S ON S.ID = FGS.SectionID
INNER JOIN
psm_ReportingTerm RT on RT.ID = FGS.reportingTermID
INNER JOIN
PSM_SectionTeacher ST ON ST.SectionID = S.ID
INNER JOIN
PSM_Teacher T ON T.ID = ST.TeacherID
INNER JOIN
psm_SchoolCourse SC on SC.ID = S.schoolcourseid
INNER JOIN
psm_School SCH on SCH.ID = S.SchoolID
LEFT JOIN
(SELECT FGS.GradingFormulaID,
MAX(CASE RTRIM(RT.name) WHEN 'Q1' THEN GFW.weighting ELSE NULL END) AS Q1,
MAX(CASE RTRIM(RT.name) WHEN 'Q2' THEN GFW.weighting ELSE NULL END) AS Q2,
MAX(CASE RTRIM(RT.name) WHEN 'Q3' THEN GFW.weighting ELSE NULL END) AS Q3,
MAX(CASE RTRIM(RT.name) WHEN 'Q4' THEN GFW.weighting ELSE NULL END) AS Q4,
MAX(CASE RTRIM(RT.name) WHEN 'E1' THEN GFW.weighting ELSE NULL END) AS E1,
MAX(CASE RTRIM(RT.name) WHEN 'E2' THEN GFW.weighting ELSE NULL END) AS E2,
MAX(CASE RTRIM(RT.name) WHEN 'R1' THEN GFW.weighting ELSE NULL END) AS R1,
MAX(CASE RTRIM(RT.name) WHEN 'R2' THEN GFW.weighting ELSE NULL END) AS R2
FROM psm_GradingFormulaWeighting GFW
INNER JOIN
psm_ReportingTerm RT on RT.ID = GFW.reportingTermID
INNER JOIN
psm_GradingFormula GF on GF.ID = GFW.ParentGradingFormulaID
INNER JOIN
PSM_FinalGradeSetup FGS on FGS.GradingFormulaID = GF.ID
WHERE RT.startDate >= TO_DATE('%param2%','MM/DD/YYYY')
GROUP BY FGS.GradingFormulaID) P
ON P.GradingFormulaID = FGS.GradingFormulaID
WHERE SCH.abbreviation = '%param1%'
AND RT.startDate >= TO_DATE('%param2%','MM/DD/YYYY')
AND RT.name = 'F1'
ORDER By T.LastName , t.FirstName, SC.Description, S.SectionIdentifier
What is limitation on joins using this tool?
I've tried multiple variations of the following SQL...which works using Oracle SQL Developer. But I'm getting no results in this tool. Even thought that a null returned value caused no records to be returned so used NVL. This is supposed to return the value of 4 custom fields:
Select '
|| S.first_name||'
|| NVL(DT1.text_value,'-') AS medtdap1 ||'
|| NVL(DT2.text_value,'-') AS medtdap2 ||'
|| NVL(V1.text_value,'-') AS medVari1 ||'
|| NVL(V2.text_value,'-') AS medVari2 ||'
'
From PS.Students S
left outer join PS.PVSIS_CUSTOM_STUDENTS DT1 On DT1.studentID = S.ID AND DT1.field_name = 'medtdap1'
left outer join PS.PVSIS_CUSTOM_STUDENTS DT2 On DT2.studentID = S.ID AND DT2.field_name = 'medtdap2'
left outer join PS.PVSIS_CUSTOM_STUDENTS V1 On V1.studentID = S.ID AND V1.field_name = 'medVari1'
left outer join PS.PVSIS_CUSTOM_STUDENTS V2 On V2.studentID = S.ID AND V2.field_name = 'medVari2'
WHERE grade_level in (%param1%)
Order by S.last_name
Solved It...
Apparently, PowerSchool does not like/cannot parse "AS".
This enhancement works...(using stored procedure)
Select '
S.first_name||'
ps_customfields.getStudentscf(id,'medtdap1') ||'
ps_customfields.getStudentscf(id,'medtdap2') ||'
ps_customfields.getStudentscf(id,'medVari1') ||'
ps_customfields.getStudentscf(id,'medVari2')
||'
'
From Students S WHERE grade_level in (%param1%)
Order by S.last_name
re: Solved It...
Yes, you shouldn't alias anything in this. In reality the alias is only used to separate fields that have the same name and/or to give the writer an easier time understanding what he/she is looking at. However in this instance you are making it 1 big string, that's what the || is doing, appending everything together so it's 1 result string. You probably could alias the entire thing, just not sure it'd help you in any way.
Jason Treadwell
Custom Solutions Specialist
jason@powerdatasolutions.org
www.powerdatasolutions.org