September 23, 2011 at 11:39 am
CREATE TABLE TABLEA
(
purpose VARCHAR(10),
contactTime datetime
)
INSERT INTO TABLEA
SELECT 'Takecare',GETDATE()
UNION ALL
SELECT 'Takecare',GETDATE()
UNION ALL
SELECT 'Takecare',GETDATE()
UNION ALL
SELECT 'welcome',GETDATE()
UNION ALL
SELECT 'welcome',GETDATE()
SELECT * FROM TABLEA
Is there any way that In one query I can get below output?
I want to know that for each purpose how many call been made for each week up to 12 week.
I can do it using writing same code for 12 time with different date range but is any other way to get the same out put?
Purpose week1 week2 week3........week12
September 23, 2011 at 11:56 am
Depending on your definition of "week1" and the like, a classic CrossTab should do it. Have a look at the related article referenced in my signature.
If you need further explanation, please post ready to use sample data as described in the first article in my sig.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply