select *,
ISNULL((ShLrbl*100),0) as AddShLrbl,
IsNULL((select [Name] from [3d_User] where [3d_User].Id=[3d_De_Cls_Record].ShrId),'') as ShrName,
ISNULL((select State from [3d_Customer_MinLrBL] where De_Id=(select distinct ParentId from [3d_De_Cls_Record] where Pid=22) and ClsId=(select distinct ClsId from [3d_De_Cls_Record] where Pid=22)),0) as LrblState, --这两个条件一样、查询字段不同
ISNULL((select Name from [3d_User] where Id=ShLrblId),'') as ShLrblName,
ISNULL((select Lr from [3d_Customer_MinLrBL] where De_Id=(select distinct ParentId from [3d_De_Cls_Record] where Pid=22) and ClsId=(select distinct ClsId from [3d_De_Cls_Record] where Pid=22)),0) as MinLr --这两个条件一样、查询字段不同
from [3d_De_Cls_Record] order by State asc,Id desc
你这是项目上的还是还在自学的东西?
如果是你在项目上写的这代码看都懒得看
如果是你在学习的东西 你去看看sql server的语法。多表连接查询 用这个来写会简单很多 你看懂了之后你再来写这个sql