12,403,983 members (69,735 online)
Rate this:
See more:
Hi
I want to create a Table dynamically according to the Values
I want to show a table

from April Month to March
```April  --
May    --
June   --
July   --
August --
Sept --
Oct --
Nov --
Dec --
Jan --
Feb --
March --
```
having two columns one for Month Names and other for Values
Values are calculated on a Formula:
```1200/12 for April 1200/11 for May ```and like wise divided by descending values and to show them accordingly against the Month Names.
How can I acheive this Please assist
Posted 17-Apr-13 20:28pm
Updated 17-Apr-13 20:54pm
Maciej Los221.8K
v2
Thomas Barbare 18-Apr-13 2:34am

What kind of db do you use ?
OriginalGriff 18-Apr-13 2:34am

What have you tried?
Where are you stuck?
Edo Tzumer 18-Apr-13 3:08am

What kind of table? HTML Table? C# Datatable? Database Table?

Rate this:

## Solution 1

If you use MS SQL Server, i recommend you to use CTE[^]:

```;WITH MyColumns
AS
(
SELECT GETDATE() AS CurrMonth, '1200/' AS FirstPart , 12 AS SecondPart
UNION ALL
SELECT DATEADD(mm,1, CurrMonth), FirstPart, SecondPart -1 AS SecondPart
FROM MyColumns
WHERE SecondPart>1
)
SELECT DATENAME(mm, CurrMonth) AS Col1, FirstPart + CASE WHEN LEN(SecondPart)=2 THEN CAST(SecondPart AS NVARCHAR(2)) ELSE '0' + CAST(SecondPart AS NVARCHAR(2)) END AS Col2
FROM MyCOlumns```

Result:
```April		1200/12
May		1200/11
June		1200/10
July		1200/09
August		1200/08
September	1200/07
October		1200/06
November	1200/05
December	1200/04
January		1200/03
February	1200/02
March		1200/01```

Top Experts
Last 24hrsThis month
 OriginalGriff 313 Richard MacCutchan 247 Karthik Bangalore 210 Suvendu Shekhar Giri 185 ppolymorphe 145
 OriginalGriff 7,386 ppolymorphe 3,175 Karthik Bangalore 3,127 Richard MacCutchan 2,372 F-ES Sitecore 2,262