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 |
|
funk.phenomena
Posting Yak Master
121 Posts |
Posted - 2011-06-17 : 17:44:07
|
| Hi All - I have the following Table with results of 1s and 0s.RECORD_NUMBER Q112654 112651 112657 012650 1I am trying to display the average of the entire column in a two digit decimal format, so the above result would generate be ".75".This code doesn't seem to work, as it only displays 1.00 or 0.00 any suggestions?CAST (AVG ([Q1]) AS DECIMAL(5,2))THANKS! |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-06-17 : 17:54:39
|
| Try: AVG(CAST [Q1] AS DECIMAL(5,2)) |
 |
|
|
jcelko
Esteemed SQL Purist
547 Posts |
Posted - 2011-06-17 : 21:16:58
|
| Why? The first rule of any tiered architecture is that all display formatting is done in the front end. Rob gave yuou the kludge, but you have more fundamental problems with SQL. If this was a woodworking newsgroup and someone posted "What is the best kind of rocks to pound screws into fine furniture?" are you really helping them when you say "Granite! Use big hunks of granite!" I am the guy who replies with "Your question is bad. Don't you know about screwdrivers?" And I like to remind them that it takes six years to become a Journeyman Union Carpenter in New York State. Not Master, Journeyman. --CELKO--Books in Celko Series for Morgan-Kaufmann PublishingAnalytics and OLAP in SQLData and Databases: Concepts in Practice Data, Measurements and Standards in SQLSQL for SmartiesSQL Programming Style SQL Puzzles and Answers Thinking in SetsTrees and Hierarchies in SQL |
 |
|
|
|
|
|