TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Akhter HUssain
721
1.3k
101.5k
Pivot table query is executing but no data return ,
May 17 2019 8:37 PM
here is my pivot table query ,it is executing but no data return.
DECLARE @cols AS NVARCHAR(MAX)
DECLARE @query AS NVARCHAR(MAX)
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SELECT DISTINCT EntryDate INTO #Dates265
FROM Probale
--WHERE (EntryDate BETWEEN @StartDate AND @Enddate)
ORDER BY EntryDate
SELECT @cols = @cols + ',' + QUOTENAME( CONVERT(varchar(20),EntryDate) )
FROM (SELECT DISTINCT DATEPART(DAY, EntryDate) AS EntryDate FROM #Dates265 ) T
ORDER BY EntryDate
--SET @cols = STUFF(@cols, 1, 1, '')
DECLARE @qry NVARCHAR(4000) =
N'SELECT *
FROM (SELECT ItemMasterFile.Descriptionitem,Probale.prdqty,
DATEPART(DAY, Probale.EntryDate)as DDate
FROM Probale Inner Join ItemMasterFile on Probale.Codeitem=ItemMasterFile.Codeitem )prd
PIVOT (Sum(prdqty) FOR DDate IN (' + @cols + ')) AS stat'
EXEC(@qry);
Reply
Answers (
2
)
How to create function which return month April to march
how to get last 8 month from 2019 and first 3 month from fin