ms sqlserver sql example

select p.long_title as title,
ps.[name] as STATUS,
i.[name] as industry,
c.[name] as category,
pc.comment as 'comment',
users.first_name + ' ' + users.last_name as commentuser,
pc.last_updated_date as commentdate ,
topicTags.tags
from presentation_comment pc
left join
presentation p
on pc.presentation_id=p.presentation_id
left join
presentation_status ps
on ps.presentation_status_id =p.presentation_status_id
left join industry i on i.industry_id = p.industry_id
left join category c on c.category_id = p.category_id
left join
users on users.user_id=pc.last_updated_user_id
left join
(
SELECT presentation_id,
tags =
(
SELECT distinct ',' + topic.[name] + ','
FROM presentation_topic tmp,
topic
WHERE topic.topic_id = tmp.topic_id AND
presentation_id = presentation_topic.presentation_id FOR
XML PATH ('')
)
FROM presentation_topic
WHERE presentation_id IS NOT NULL
GROUP BY presentation_id
) topicTags
on topicTags.presentation_id = p.presentation_id
left join
(
SELECT presentation_id,
speaker =
(
SELECT ',' + ps. + ','
FROM presentation tmp,
presentation_speaker ps
WHERE topic.topic_id = tmp.topic_id AND
presentation_id = presentation_topic.presentation_id FOR
XML PATH ('')
)
FROM presentation_topic
WHERE presentation_id IS NOT NULL
GROUP BY presentation_id
) topicSpeakers
on topicSpeakers.presentation_id=p.presentation_id
where users.user_id=1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值