<\/span><\/h2>\n\n\n\nYou are given two tables: Students<\/em> and Grades<\/em>. Students<\/em> contains three columns ID<\/em>, Name<\/em> and Marks<\/em>.<\/p>\n\n\n\nColumn<\/th> | Type<\/th><\/tr><\/thead> |
---|
ID<\/em><\/td>Integer<\/em><\/td><\/tr>Name<\/em><\/td>String<\/em><\/td><\/tr>Marks<\/em><\/td>Integer<\/em><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n Grades<\/em> contains the following data:<\/p>\n\n\n\nGrade<\/th> | Min_Mark<\/th> | Max_Mark<\/th><\/tr><\/thead> |
---|
1<\/em><\/td>0<\/em><\/td>9<\/em><\/td><\/tr>2<\/em><\/td>10<\/em><\/td>19<\/em><\/td><\/tr>3<\/em><\/td>20<\/em><\/td>29<\/em><\/td><\/tr>4<\/em><\/td>30<\/em><\/td>39<\/em><\/td><\/tr>5<\/em><\/td>40<\/em><\/td>49<\/em><\/td><\/tr>6<\/em><\/td>50<\/em><\/td>59<\/em><\/td><\/tr>7<\/em><\/td>60<\/em><\/td>69<\/em><\/td><\/tr>8<\/em><\/td>70<\/em><\/td>79<\/em><\/td><\/tr>9<\/em><\/td>80<\/em><\/td>89<\/em><\/td><\/tr>10<\/em><\/td>90<\/em><\/td>99<\/em><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n Ketty<\/em> gives Eve<\/em> a task to generate a report containing three columns: Name<\/em>, Grade<\/em> and Mark<\/em>. Ketty<\/em> doesn’t want the NAMES of those students who received a grade lower than 8<\/em>. The report must be in descending order by grade — i.e. higher grades are entered first. If there is more than one student with the same grade (8-10) assigned to them, order those particular students by their name alphabetically. Finally, if the grade is lower than 8, use “NULL” as their name and list them by their grades in descending order. If there is more than one student with the same grade (1-7) assigned to them, order those particular students by their marks in ascending order.<\/p>\n\n\n\nWrite a query to help Eve.<\/p>\n\n\n\n Sample Input<\/strong><\/p>\n\n\n\nId<\/th> | Name<\/th> | Marks<\/th><\/tr><\/thead> |
---|
1<\/em><\/td>Julia<\/em><\/td>88<\/em><\/td><\/tr>2<\/em><\/td>Samantha<\/em><\/td>68<\/em><\/td><\/tr>3<\/em><\/td>Maria<\/em><\/td>99<\/em><\/td><\/tr>4<\/em><\/td>Scarlet<\/em><\/td>78<\/em><\/td><\/tr>5<\/em><\/td>Ashley<\/em><\/td>63<\/em><\/td><\/tr>6<\/em><\/td>Jane<\/em><\/td>81<\/em><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n Sample Output<\/strong><\/p>\n\n\n\nMaria 10 99\nJane 9 81\nJulia 9 88 \nScarlet 8 78\nNULL 7 63\nNULL 7 68<\/code><\/pre>\n\n\n\nNote<\/strong><\/p>\n\n\n\nPrint “NULL” as the name if the grade is less than 8.<\/p>\n\n\n\n <\/span>Explanation<\/strong><\/span><\/h2>\n\n\n\nConsider the following table with the grades assigned to the students:<\/p>\n\n\n\nId<\/th> | Name<\/th> | Marks<\/th> | Grade<\/th><\/tr><\/thead> |
---|
1<\/em><\/td>Julia<\/em><\/td>88<\/em><\/td>9<\/em><\/td><\/tr>2<\/em><\/td>Samantha<\/em><\/td>68<\/em><\/td>7<\/em><\/td><\/tr>3<\/em><\/td>Maria<\/em><\/td>99<\/em><\/td>10<\/em><\/td><\/tr>4<\/em><\/td>Scarlet<\/em><\/td>78<\/em><\/td>8<\/em><\/td><\/tr>5<\/em><\/td>Ashley<\/em><\/td>63<\/em><\/td>7<\/em><\/td><\/tr>6<\/em><\/td>Jane<\/em><\/td>81<\/em><\/td>9<\/em><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n So, the following students got 8<\/em>, 9<\/em> or 10<\/em> grades:<\/p>\n\n\n\n | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | |