A SQL query statement that is super difficult to query the name of the teacher and the name of the c

Updated on technology 2024-03-21
4 answers
  1. Anonymous users2024-02-07

    declare @teacher varchar(50)

    set @teacher='Yang Chuntao'

    select * from (

    select language as subject, bjh from table where language = @teacher

    union all

    select math as subject, bjh from table where math = @teacher

    union all

    select English as subject, bjh from table where English = @teacher

    union all

    select Item as Subject, BJH from Table where Item = @teacher

    union all

    select History as Subject, BJH FROM Table where History = @teacher

    union all

    Select Geography as Subject, BJH from Table Where Geography = @teacher

    union all

    Select Biology as Subject, BJH FROM Table Where Biology = @teacher

    as result

  2. Anonymous users2024-02-06

    The design of the table is unreasonable, if the teacher changes his name, or if Teacher Yang Chuntao leaves, his classes will all be replaced by Zhang San.

    Your update statement is also hard to write.

    Generally you should have this design.

    Teacher Sheet: ID Name Other Information.

    Class Schedule: BJH Course Name Teacher ID

    It's easy to query, insert updates, and so on.

  3. Anonymous users2024-02-05

    The idea is to group first and then sort by grade.

  4. Anonymous users2024-02-04

    What is the structure of your data?

    Whether the total score has been calculated.

    It is assumed that the total score has been calculated.

    All the records of the top 3 can be customized (list the total score of the top 3 results, and write 3 mainstream databases).

    sqlserver database:

    Select Top 3 from Score Sheet Order by Total Score DESC

    MySQL Database:

    select * from Score Sheet Order by DESC Total Score DESC Limit 3

    Oracle Database:

    select * from Grade Sheet Order by Desc Total Score Rownum < = 3

    If the total score is not given.

    The total score needs to be calculated first.

    select (Chinese + Mathematics +. as total top 3 from transcript order by total desc

    Then the other databases themselves can flexibly use the above methods of the database you are using.

Related questions
9 answers2024-03-21

You weren't specific enough, how old are you? How old are your teachers? What is the age gap between you? >>>More

4 answers2024-03-21

1. Dogs. Dogs (Latin canis lupus familiaris) belong to the phylum Chordates, subphylum Vertebrates, Mammalia, Euzos, Carnivores, Schizopoda, Canidae. Also known as "dog" in Chinese, dogs are found all over the world. >>>More

1 answers2024-03-21

During this winter vacation, I had the privilege of reading Professor Wei Shusheng's book "I Do This as a Teacher". In this book, Professor Wei provides a profound analysis of how teachers can use the right teaching methods to better educate students. It also enables teachers to experience more sense of accomplishment and happiness in their work. >>>More

3 answers2024-03-21

Find out who you love the most in three minutes? (98% accuracy?) ) >>>More

22 answers2024-03-21

Punishment doesn't work, it's like a flood, the more you block, the more fierce it becomes. Constant criticism can only lead to children uniting against you. It's not a bad thing for children to be mischievous, it's just that they're putting their energy to the wrong place. >>>More