日期:2014-05-18 浏览次数:20496 次
SELECT pkd.ID, Convert(varchar(10),pkl.ViewDate,111) as ViewTime, CONVERT(VARCHAR, pkd.InitialDate) as UploadTime, pkd.ProductLine as ProductLine, pkd.Model as model, pkd.SerialNo as SerialNo, begin select account, case when (account ! ='') then (select account from NTUser where NTUser.[ID] = pkl.viewBy) as UserAccount, (select name from UserSite u,site s where u.siteid=s.id) as sitename, 'big' as UserType, else (select account from member where member.[ID] = pkl.viewBy) as UserAccount, (select country from UserSite u,regioncountry c where u.siteid=c.siteID) as sitename, 'small' as UserType, end from NTUser, end FROM pkbknowledgedetail pkd,PKBViewLog pkl WHERE Status = 'A' and pkl.KnowLedgeID = pkd.[ID] and viewBy='ASfde0ea4b-4fbf-41af-b4ae-78215f295cbf' 小弟不胜感激啊
建议你提供详细的资料: 例如表的结构,表之间的关系,测试数据,相关算法及需要的结果。 这样有助于我们理解你的意思,更主要的是能尽快让你获得答案或解决问题的方法。
------解决方案--------------------
SELECT pkd.ID, Convert(varchar(10),pkl.ViewDate,111) as ViewTime, CONVERT(VARCHAR, pkd.InitialDate) as UploadTime, pkd.ProductLine as ProductLine, pkd.Model as model, pkd.SerialNo as SerialNo,???从哪儿查??后面的呢? begin select account, case when (account ! ='') then (select account from NTUser where NTUser.[ID] = pkl.viewBy) as UserAccount, (select name from UserSite u,site s where u.siteid=s.id) as sitename, 'big' as UserType--都好多余 else (select account from member where member.[ID] = pkl.viewBy) as UserAccount, (select country from UserSite u,regioncountry c where u.siteid=c.siteID) as sitename, 'small' as UserType, end from NTUser, end FROM pkbknowledgedetail pkd,PKBViewLog pkl WHERE Status = 'A' and pkl.KnowLedgeID = pkd.[ID] and viewBy='ASfde0ea4b-4fbf-41af-b4ae-78215f295cbf' 这个错误太多了,给测试数据和结果吧,不带这么写的
------解决方案--------------------
不带这么写的,你说出来有哪些东西,想干什么,也许会有更好的解决方法。
------解决方案--------------------
楼主,小弟我投降了
------解决方案--------------------
------解决方案--------------------
支持楼主--精神
------解决方案--------------------
;WITH m1 AS ( SELECT account , (SELECT account FROM NTUser WHERE NTUser.[ID] = pkl.viewBy) AS UserAccount , (SELECT name FROM UserSite u ,site s WHERE u.siteid = s.id) AS sitename , 'big' AS UserType FROM NTUser WHERE account ! = '' UNION ALL SELECT account , (SELECT account FROM member WHERE member.[ID] = pkl.viewBy), (SELECT country FROM UserSite u ,regionc