返回表的查询

时间:2015-03-30 06:39:00

标签: mysql sql-server sql-server-2008 sql-server-2008-r2 sql-server-2012

有人可以帮助查询返回所有最新JOHN更新的表格。

From LeadManagement$StatusLog
Get createdDate, StatusFrom, StatusTo
WHERE MandyOrJOHNStatus = 'JOHN'
And the createdDate is between the date range you want to look at.
Order by createDate Descending and Distinct by JOHNAppID (below)
Join with LeadManagement$StatusLog_Lead to LeadManagement$Lead
To Get LeadNumber, JOHNAppID and JOHNBrandAppID

1 个答案:

答案 0 :(得分:0)

我不清楚你在这里想要什么...但我相信以下查询可能对你有所帮助

SELECT LMS.createdDate,
       LMS.StatusFrom,
       LMS.StatusTo,
       LMSS_L.LeadNumber,
       DISTINCT (LMSS_L.JOHNAppID) ,JOHNBrandAppID
FROM   LeadManagement$StatusLog LMS
JOIN   LeadManagement$Lead LML ON *common column in both* 
JOIN   LeadManagement$StatusLog_Lead LMSS_L ON *common column in both*  
WHERE  MandyOrJOHNStatus = 'JOHN'
  AND  createdDate BETWEEN *the date range you want to look at*
ORDER BY createDate DESC

这个解决方案只是据我所知,希望它有所帮助。