-
The answer on the 1st floor was incorrect, and the results were not read.
Let's talk about the idea, create three sub-tables (Chinese, Mathematics, English) to store Chinese scores, mathematics scores, and English scores respectively, and each table only contains two fields (name and subject score).Then combine the three sub-tables according to the same name. The following is SQL, which has been executed, so feel free to use it.
select language. Name, language. Chinese, Mathematics. Mathematics, English. English.
from (select name, grade as language.)
from student
where (subject =.)'Language')) as language inner join
Select Name, Grades as Maths.
from student
where (subject =.)'Mathematics')) as mathematics on language. Name = Mathematics. Name inner join
Select Name, Grades as English.
from student
where (subject =.)'English. ')) as English on Language. Name = English. Name.
-
select a1.Name, A1Language, A2Mathematics, A3English.
from (select name, grade as language.)
from student
where (subject =.)'Language'a1 inner joinselect name, grade as math.
from student
where (subject =.)'Mathematics') a2 on a1.Name = A2Name inner join
Select Name, Grades as English.
from student
where (subject =.)'English. ') a3 on a2.Name = a3Name.
-
Name Subject Grade.
Zhang San Language 80
Zhang San Math 90
Zhang San English 81
Li Si Language 78
Li Si Mathematics 69
Li Si English 97
The above table is named a
select Table 1Name as Name, Language, Mathematics, English from select Name, Grade as Language from a whre Subject='Language') as Table 1 ,select name, grade as math from a whre subject='Mathematics') as Table 2 , select name, grade as English from a whre subject='English. 'as Table 3
where Table 1Name = Table 2Name and Table 2Name = Table 3Name.
-
Select Name, AGrades as Language, BGrades as Mathematics, CGrades as English.
fromselect name, grade from student where subject='Language') a,select name,grade from student where subject='Mathematics') b,select name,grade from student where subject='English. ') c
where a.Name = bName and aName = cName.
-
Hehe, there is a simple way to write it, no need to build a sub-table.
select a.Name = bGrades Yuwen, C
Grades Shuxue, DGrades Yingyu from Student A, Student B, Student C, Student D
where a.Name = bName and aName = cName and aName = dName.
and b.Subjects ='Language' and c.Subjects ='Mathematics' and d.Subjects ='English. '
It's simple, OK.
-
Upstairs says subqueries, and you can query them with links!
Tomorrow to revise the problem!
Write you a link query.
-
Alas, there is a problem with your table construction, which is why your query statement is so complicated to write.
F get domain contrast is a formatting function (should be written by yourself), the first parameter (arg prod spec id) according to the second parameter (120) formatting and return the result to the v bill code, according to the function naming method, the above ** should be the standard format for getting the date.
With a view or an index.
create index >>>More
Generally refers to indexing. You don't have to.
You need to write a stored procedure that can do the above functionality! After all, what you're describing has a branching structure!
select
from[Table name]. >>>More