有3个表    Car,User,User_Car 要得到一个用户对应有几种车。

   SQl:

select Uname as 姓名,
MAX(case Name when '宝马' then Smoney end) '宝马',
MAX(case Name when '奔驰' then Smoney end) '奔驰',
MAX(case Name when '大众' then Smoney end) '大众'
from
(select u.Uname,c.Name,uc.Smoney
from dbo.Car c ,dbo.Users u,dbo.User_Car uc
where c.ID = uc.CID and u.ID=uc.[UID]) aa
group by aa.Uname

相关文章:

  • 2021-11-08
  • 2022-12-23
  • 2021-10-17
  • 2022-02-19
  • 2021-05-28
  • 2022-12-23
  • 2021-12-22
  • 2021-05-23
猜你喜欢
  • 2021-12-15
  • 2022-12-23
  • 2021-08-17
  • 2022-12-23
  • 2021-12-15
  • 2021-12-30
相关资源
相似解决方案