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.
Author |
Topic |
cplusplus
Aged Yak Warrior
567 Posts |
Posted - 2014-02-25 : 10:05:17
|
I need to calculate the Average, from table encounteri have the below three columns, how i can put the logic within the select querysum(disch_date - admit_date)/ count(distinct encounter_id)Thank you very much for the helpful info. |
|
RonnieRahman
Starting Member
6 Posts |
Posted - 2014-02-25 : 10:20:15
|
Have you tried AVG ( [ ALL | DISTINCT ] expression ) Here is the link: [url]http://technet.microsoft.com/en-us/library/ms177677(v=sql.105).aspx[/url] |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2014-02-25 : 11:30:57
|
SUM(DATEDIFF(DAY, Admit_Date, Disch_Date)) / COUNT(DISTINCT Encounter_ID) Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
|
|
|