Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Please help me with queryI have table like App's, server, Count. I need to calculate count based on App'sscenario: server can share multiple applicaions for exampleServer1234App'sabcdbabbccnnthen count column should be like belowcount0.25 ( in this case server is sharing with 4 diffrent applications)Example 2:server23213App'sgdggsgcount0.5ThanksAswin
James K
Master Smack Fu Yak Hacker
3873 Posts
Posted - 2013-04-12 : 16:36:54
Can you try if either of the following gives you what you are looking for?
SELECT Apps, Server, 1.0/COUNT(*) OVER (PARTITION BY server) AS [count]FROM TblSELECT [Server], 1.0/COUNT(*) AS [count]FROM TblGROUP BY Server
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2013-04-13 : 02:06:30
you want the App's also to be listed? also should they come in same row or separate rows?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs