Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Updated :Count and find last Occurrence of value ?

Author  Topic 

MSSQLRahzel
Starting Member

1 Post

Posted - 2013-01-28 : 08:40:52
Below you will see that I have manually found the last occurrence of each value for each row. Each row will be scanned for the same 0-9 MB until last occurrence is found. What would be the best way to automate this ? If you manually count what each column name in "green" is searching for you will see my objective. Example would be 1MB column is searching for 1MB.

NOTE "Green" columns are searching for the last occurrence of that specific column name in "ANY" "Pink" column. Example Column 4MB will search Server1,Server2,Server3 per row until last occurrence of 4MB is found.

Any help would be greatly appreciated. Thanks
[Date] [date]
[Server1] [nvarchar](25)
[Server2] [nvarchar](25)
[Server3] [nvarchar](25)
[0MB] [int](5)
[1MB] [int](5)
[2MB] [int](5)
[3MB] [int](5)
[4MB] [int](5)
[5MB] [int](5)
[6MB] [int](5)
[7MB] [int](5)
[8MB] [int](5)
[9MB] [int](5)

HERE IS THE IMAGE

http://i1309.photobucket.com/albums/s621/Rahzel_Shaun_Harris/73DB5921-B1BE-447D-81BA-3D01C9955140-301-0000002C91DEEB8F_zps25b3fa88.jpg


http://i1309.photobucket.com/albums/s621/Rahzel_Shaun_Harris/73DB5921-B1BE-447D-81BA-3D01C9955140-301-0000002C91DEEB8F_zps25b3fa88.jpg "/>

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-01-28 : 08:48:50
looks like pivotting to me

http://beyondrelational.com/modules/2/blogs/70/posts/10840/dynamic-pivot-in-sql-server-2005.aspx

http://beyondrelational.com/modules/2/blogs/70/posts/10791/dynamic-crosstab-with-multiple-pivot-columns.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -