logId int identity(1,1) not null primary key,--日志ID
commentLogId varchar(10),--日志IDlogTypeId int identity(1,1) not null primary key,--日志类型ID
logType varchar(10) not null,--日志类型(日志类型表)
字段的数据类型怎么不一样?select
lt.logTypename,
lg.logTitle,
sum(case when ct.commentTime is null then 0 else 1 end)as ct
from
dbo.logs lg
inner join
dbo.logType lt
on
lg.userid = lt.userid and lg.logType = lt.logTypeId
left join
dbo.comments ct
On
ct.userid = lg.userid and ct.commentLogId = lg.logId
group by
lt.logTypename, lg.logTitle
commentLogId varchar(10),--日志IDlogTypeId int identity(1,1) not null primary key,--日志类型ID
logType varchar(10) not null,--日志类型(日志类型表)
字段的数据类型怎么不一样?select
lt.logTypename,
lg.logTitle,
sum(case when ct.commentTime is null then 0 else 1 end)as ct
from
dbo.logs lg
inner join
dbo.logType lt
on
lg.userid = lt.userid and lg.logType = lt.logTypeId
left join
dbo.comments ct
On
ct.userid = lg.userid and ct.commentLogId = lg.logId
group by
lt.logTypename, lg.logTitle
'['+lt.logTypename+']'+
lg.logTitle as Title,
'评论('+cast(sum(case when ct.commentTime is null then 0 else 1 end) as varchar) +')' as comment
from
dbo.logs lg
inner join
dbo.logType lt
on
lg.userid = lt.userid and lg.logType = lt.logTypeId
left join
dbo.comments ct
On
ct.userid = lg.userid and ct.commentLogId = lg.logId
group by
'['+lt.logTypename+']'+
lg.logTitle