dods26
SSC Enthusiast
Points: 153
More actions
December 10, 2014 at 8:40 am
#313661
Hi Gurus,
Is there way in SQL query to get the count of certain data that would display the last month's data and current month's data. For example...
SELECT count(prt_created = lastMonth) as lastMonthData,count(prt_created = currentMonth) as currentMonthDataFROM PARTICIPLES
SELECT count(prt_created = lastMonth) as lastMonthData,
count(prt_created = currentMonth) as currentMonthData
FROM PARTICIPLES
Something like above... where I can display their count on the table rows..
Last Month | This Month 10 | 11 12 | 9
Last Month | This Month
10 | 11
12 | 9
spaghettidba
SSC Guru
Points: 105732
December 10, 2014 at 8:56 am
#1763821
It's a crosstab:
SELECT SUM(CASE WHEN prt_created = lastMonth THEN 1 ELSE 0 END) as lastMonthData,
SUM(CASE WHEN prt_created = currentMonth THEN 1 ELSE 0 END) as currentMonthData
Hope this helps
-- Gianluca Sartori
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply