Table: markdetails

## studid ## ## subjectid ##  ## marks ##
     A1            3                50
     A1            4                60
     A1            5                70
     B1            3                60
     B1            4                80
     C1            5                95

Table: student info

## studid ##  ## name ##
      A1          Raam
      B1          Vivek
      c1          Alex


Result: 

## studid ## ## name## ## subjectid_3 ## ## subjectid_4 ## ## subjectid_5 ##
      A1        Raam        50                60                 70
      B1        Vivek       60                80                null
      c1        Alex       null              null                95


 SQLite:

select
    u.stuid,
    u.name,
    s3.marks as subjectid_3,
    s4.marks as subjectid_4,
    s5.marks as subjectid_5
from
    student_temp u
    left outer join markdetails s3 on
        u.stuid = s3.stuid
        and s3.subjectid = 3
    left outer join markdetails s4 on
        u.stuid = s4.stuid
        and s4.subjectid = 4
    left outer join markdetails s5 on
        u.stuid = s5.stuid
        and s5.subjectid = 5

相关文章:

  • 2021-07-14
  • 2021-12-12
  • 2021-05-20
  • 2021-10-18
  • 2021-07-22
  • 2021-11-14
  • 2021-08-03
  • 2021-04-21
猜你喜欢
  • 2021-12-22
  • 2022-12-23
  • 2021-12-17
  • 2021-06-29
  • 2022-01-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案