SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Updated :Count and find last Occurrence of value ?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

MSSQLRahzel
Starting Member

1 Posts

Posted - 01/28/2013 :  08:40:52  Show Profile  Reply with Quote
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




Edited by - MSSQLRahzel on 01/28/2013 14:31:09

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 01/28/2013 :  08:48:50  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000