Something like this..
SELECT L_Limit,
U_Limit,
SUM(CASE
WHEN DATEDIFF(day, Timestamp, CURRENT_TIMESTAMP) = 0 THEN Asset
ELSE 0
END) AS Asset_Today,
SUM(CASE
WHEN DATEDIFF(day, Timestamp, CURRENT_TIMESTAMP) = 7 THEN Asset
ELSE 0
END) AS Asset_Before7Days,
SUM(CASE
WHEN DATEDIFF(day, Timestamp, CURRENT_TIMESTAMP) = 30 THEN Asset
ELSE 0
END) AS Asset_Before30Days
FROM YourTableName -- Replace with you table name
WHERE DATEDIFF(day, Timestamp, CURRENT_TIMESTAMP) IN ( 0, 7, 30 )
GROUP BY L_Limit,
U_Limit
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/