And MySQL in contrast to see: http://blog.csdn.net/rainyspring4540/article/details/50231435
This is the oracle10g environment.
The database structure is as follows:
If I want to show the same name on the same line, there are 2 basic shows:
First presentation (displayed on different columns of the same row)
Its SQL is as follows:
Select Name,
max (decode (type, ' math ', score,0) as math,
max (decode (type, ' 中文版 ', score,0)) as English,
Max ( Decode (Type, ' Chinese ', score,0)) as language from
stu2
GROUP by name
Because a person here only corresponds to a subject's score, all you use Max and sum is the same, if a person has multiple grades in one subject, then sum is the meaning of summation, and Max is to take the maximum, I will not write cases, their own attention to OK
Second show (shown on the same column in the same row)
SQL is as follows:
Select Name,
max (decode (type, ' math ', score,0)) |
| Max (decode (type, ' 中文版 ', score,0)) |
| | Max (decode (type, ' Chinese ', score,0)) as Allscore from
stu2
GROUP by name
If you are familiar with string stitching | | Use to make more styles:
Style 1: