![]() ![]() ![]() ![]() |
|||||
|
|||||
樓主 雲林仔 ![]()
![]() |
因為會有類似下列的語法 但一次會從三個不同的資料表來抓出,而因為是個別資料表,將會依照username來對應名稱,將抓到的該username的likes,content,loginrecord筆數儲存到對應的帳號,有辦法將其合併在一塊來設定為單一個sqldatasource嗎? 謝謝
搜尋相關Tags的文章:
[ table ] ,
本篇文章發表於2015-11-08 22:36 |
1樓 |
像這種?
本篇文章回覆於2015-11-09 10:01
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔-- |
2樓 |
create procedure proc_cnt
as select count(*) as 次數,likes.username into #likes from likes where creationdate between '2015/10/9' and '2015/10/17'group by likes.username select count(*) as 次數 ,content.creator into #content from content where creationdate between '2015/10/9' and '2015/10/17'group by content.creator select count(*)as 次數,loginrecord.username into #loginrecord from loginrecord where creationdate between '2015/10/9' and '2015/10/17'group by loginrecord.username create table #temp(username nvarchar(50)) insert #temp select distinct username from likes where creationdate between '2015/10/9' and '2015/10/17' insert #temp select distinct content.creator from content where creationdate between '2015/10/9' and '2015/10/17' and content.creator not in(select username from temp) insert #temp select distinct loginrecord.username from loginrecord where creationdate between '2015/10/9' and '2015/10/17' and loginrecord.username not in(select username from temp) alter table #temp add likescount numeric(18,2) alter table #temp add contentcount numeric(18,2) alter table #temp add loginrecordcount numeric(18,2) update #temp set likescount=#likes.次數 from temp join #likes on temp.username=#likes.username update #temp set likescount=#content.次數 from temp join #content on temp.username=#content.creator update #temp set likescount=#loginrecord.次數 from temp join #loginrecord on temp.username=#loginrecord.username select * from #temp
本篇文章回覆於2015-11-09 10:24
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔-- |
回覆 |
如要回應,請先登入. |