.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
ASPEvil
david stephan
Santhakumar Munuswamy
Fauzul Azmi
Post New Web Links

T-SQL

Posted By:      Posted Date: September 14, 2010    Points: 0   Category :Sql Server
 
Hi........ I Want To Make This 2 Different CTE To One... WITH B AS ( SELECT SUM(Hrs) AS Hrs, D.PNo AS No, SUM(D.Cost) AS Cost FROM ( SELECT DATEDIFF(MINUTE,A.StartTime,A.EndTime)/60.0 AS Hrs, COALESCE(P.DNo,C.PNo,') AS PNo, (R.Rate*(DATEDIFF(MINUTE,A.StartTime,A.EndTime)/60.0)) AS Cost FROM Activity A LEFT OUTER JOIN P ON ( P.DNo = A.CNo ) LEFT OUTER JOIN ( SELECT F.DNo, P.DNo AS No FROM F INNER JOIN Q ON ( Q.Id = F.QId ) INNER JOIN P ON ( P.Id = Q.PId ) )C ON ( C.DNo = A.CNo ) INNER JOIN R ON ( R.Id = A.RId ) WHERE (P.DNo IS NOT NULL OR C.PNo IS NOT NULL) AND (A.TId = 1 OR A.TId = 2) )D GROUP BY D.PNo ) , E AS ( SELECT SUM(Hrs) AS Hrs, D.PNo AS No, SUM(D.Cost) AS Cost FROM ( SELECT DATEDIFF(MINUTE,A.StartTime,A.EndTime)/60.0 AS Hrs, COALESCE(P.DNo,C.PNo,') AS PNo, (R.Rate*(DATEDIFF(MINUTE,A.StartTime,A.EndTime)/60.0)) AS Cost FROM Activity A LEFT OUTER JOIN P ON ( P.DNo = A.CNo ) LEFT OUTER JOIN ( SELECT F.DNo, P.DNo AS No FROM F INNER JOIN Q ON ( Q.Id = F.QId ) INNER JOIN P ON


View Complete Post


More Related Resource Links

Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend