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
 General SQL Server Forums
 New to SQL Server Programming
 query help

Author  Topic 

aswindba1
Yak Posting Veteran

62 Posts

Posted - 2013-04-12 : 15:21:57
Please help me with query

I have table like App's, server, Count. I need to calculate count based on App's
scenario: server can share multiple applicaions for example

Server
1234

App's
abc
dba
bbc
cnn

then count column should be like below

count
0.25 ( in this case server is sharing with 4 diffrent applications)

Example 2:

server
23213

App's
gdg
gsg

count
0.5

Thanks
Aswin

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
Tbl

SELECT
[Server],
1.0/COUNT(*) AS [count]
FROM
Tbl
GROUP BY
Server
Go to Top of Page

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 MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -