I have a stored procedure which returns Id, FileContent and description of Images used in a project. I have a requirement to display the images in 3 by 3 format . I know we can do it in a table either vertically or horizontally but how can i get it 3 by 3 like below.
Image1 Image2 Image 3
Image4 Image5 Image 6
this is little bit tricky ... try to get output of SQL query like this
Declare @Image AS Table(ImageName Varchar(50))
Declare @N AS INT
Set @N=3 -- N X N Matrix
Insert into @Image Values('Image1'),('Image2'),('Image3'),
('Image4'),('Image5'),('Image6'),
('Image7'),('Image7'),('Image8')
Select *,
Case (RowNum % @N)
When 0 then Char(64 + RowNum / @N)
ELSE Char(65 + RowNum / @N) END AS Grp
From
(Select row_number() Over(order by Imagename) AS RowNum,ImageName From @Image
) Result
See output looks like
now what you have to do take a matrix and do a row grouping by [grp] column & column grouping on ImageName...
your report will look like; cheers :-)