Null values in an expression

Null values in an expression

by John Samuel -
Number of replies: 5

Good Day Gentelmen!

How do i include ' NULL'  Values in this expression???

where gg.timemodified>0

Thanks

Average of ratings: -
In reply to John Samuel

Re: New plugin: Custom reports

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

WHERE (gg.timemodified>0 OR gg.timemodified IS NULL)

In reply to Tim Hunt

Re: New plugin: Custom reports

by John Samuel -

@TIM

Thank you for the help, i tried that syntax to show the NULL grades but didn't work.

ROUND(gg.finalgrade,2) AS Grade, ...  anything i am missing here? i just want to see Null grades as well.

Thanks,

John Sam

In reply to John Samuel

Re: New plugin: Custom reports

by Juan Leyva -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Can you post here the full sql query?

In reply to Juan Leyva

Re: New plugin: Custom reports

by John Samuel -

Here it is, it doesn't show the NULL  finalgrades.

______________________________________________________________

 

SELECT co.fullname as 'Course', u.username as 'Emp ID', u.country as 'Location', u.firstname, u.lastname, ROUND(gg.finalgrade,2) AS Grade, FROM_UNIXTIME(ra.timemodified,'%D %M %h:%i:%s %x') AS Enrol_time

FROM prefix_role_assignments ra,

prefix_user u, prefix_context c, prefix_course co, prefix_grade_grades gg, prefix_grade_items gi, prefix_course_categories cc

WHERE ra.contextid = c.id AND c.instanceid = co.id AND c.contextlevel = 50 AND ra.userid = u.id AND u.deleted = 0  AND gg.userid = u.id AND gi.itemtype = 'course' AND cc.id = co.category AND gi.courseid = co.id AND gi.id = gg.itemid

%%FILTER_COURSES:co.id%% %%FILTER_STARTTIME:ra.timemodified:>%% %%FILTER_ENDTIME:ra.timemodified:<%% %%FILTER_USERS:u.country%%  

In reply to John Samuel

Re: New plugin: Custom reports

by Juan Leyva -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

This query should show NULL final grades (if they are present in tables)

Please, try to change this:

 ROUND(gg.finalgrade,2) AS Grade

for

gg.finalgrade AS Grade

Regards