How to merge two rows into one row in sql?

前端 未结 2 1600
Happy的楠姐
Happy的楠姐 2021-02-07 22:26

I have a table as

EmployeeID    IndividualPay  FamilyPay   IsActive
    1            200          300        true
    1            100          150        false
         


        
2条回答
  •  闹比i
    闹比i (楼主)
    2021-02-07 23:11

    Select
        EmployeeID,
        Active.IndividualPay As IndPay_IsActive,
        Active.FamilyPay As FamilyPay_IsActive,
        Inactive.IndividualPay As IndPay_IsNotActive,
        Inactive.FamilyPay As FamilyPay_IsNotActive
    From
        PayTable Active
        Join PayTable Inactive On Active.EmployeeID = Inactive.EmployeeId
            And Inactive.IsActive = 'false'
    Where
        Active.IsActive = 'true'
    

提交回复
热议问题