Home > database >  SQL statements for help
SQL statements for help

Time:11-10

  no class in this field, how to calculate the average score of classes, the class can only student number, student id known rules for a year in + number + 2 two college class number within + 2 class number

CodePudding user response:

 
SELECT the LEFT (student id, 6), AVG (English) FROM league tables GROUP BY LEFT (student id, 6)

CodePudding user response:

Thanks for elder brother understand

CodePudding user response:

reference 1/f, big watermelon cut a piece of a kilo of reply:
 
SELECT the LEFT (student id, 6), AVG (English) FROM league tables GROUP BY LEFT (student id, 6)
eldest brother, this use case the when, judge conditions how to write

CodePudding user response:

DECLARE @ A DECIMAL (12, 1)

The SET @ A=92.5

SELECT A CASE WHEN @ A * 10 - FLOOR (@ A/10) * 100 & lt;=25 THEN FLOOR (@ A/10)
The WHEN @ A * 10 - FLOOR (@ A/10) * 100 & gt; 25 AND @ A * 10 - FLOOR (@ A/10) * 100 & lt;=75 THEN FLOOR (@ A/10 * 10 + 5
The ELSE FLOOR (@ A/10 * 10 + 10
END
  • Related