|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Thursday, August 09, 2012 12:33 AM
Points: 21,
Visits: 60
|
|
Hi,
I need to display current week as 0 for any year in the report......using week column in week table.
I have week values like wk1,wk2.....wk53 for 3 years from 2009 to 2011.........
I need to display current week as 0 irrespective of any year if user selects.......
Can any one provide the sql function for this......
Thanks Gopi
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Today @ 1:36 PM
Points: 887,
Visits: 2,062
|
|
CREATE TABLE #WeekTable( YearCol INT ,WeekCol VARCHAR(9) );
INSERT INTO #WeekTable (YearCol, WeekCol) SELECT 2009, 'wk1' UNION ALL SELECT 2009, 'wk31' UNION ALL SELECT 2009, 'wk52' UNION ALL SELECT 2010, 'wk1' UNION ALL SELECT 2010, 'wk31' UNION ALL SELECT 2010, 'wk52' UNION ALL SELECT 2011, 'wk1' UNION ALL SELECT 2011, 'wk31' UNION ALL SELECT 2011, 'wk52'
SELECT [Week] = CASE WHEN REPLACE(WeekCol, 'wk', '') = DATEPART(wk, CURRENT_TIMESTAMP) THEN '0' ELSE WeekCol END ,* FROM #WeekTable;
DROP TABLE #WeekTable;
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Thursday, August 09, 2012 12:33 AM
Points: 21,
Visits: 60
|
|
Hi,
Thanks for the details but I don't have access to run these commands in our db. I can access from report end....
Means I need to use whatever tables already there in my package as I told you earlier.....I need to use Merchandise week table from my package which is having values like wk1,wk2.....wk53 for each year..
Only thing I can do is use the fucntions which is there in report level like date functions or case,if,for anything to get our output.
Thanks Gopi
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Today @ 1:36 PM
Points: 887,
Visits: 2,062
|
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Thursday, August 09, 2012 12:33 AM
Points: 21,
Visits: 60
|
|
Hi,
I can't execue these cmsds in our database since I don't have rights to do that. I was talking about the Cognos Reports where I have to implement this logic to run my report.
Thanks Gopi
|
|
|
|