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 |
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2007-08-03 : 08:50:09
|
| Hi,I have a table as shown with the CREATE table statement below. I am looking to find a way to run a query that shows on average what how full each row is according to its "response" column, and I want to break that down by questionID. It would be ok to hardcode the value of "750" as the maximum (100% full column)How would I go about doing this ? A desired resultset would be formatted like this below.Thanks very much for any assistance!!mike123questionID,averageFillPercentage,averageCharacters1, 50% ,3752, 23% ,172.53, 90% ,6754, 11% ,82.55, 65% ,487.5CREATE TABLE [dbo].[tblQuestions]( [userID] [int] NOT NULL, [questionID] [tinyint] NOT NULL, [response] [varchar](750) NULL)GO |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-08-03 : 08:59:57
|
| select questionid,cast(response as float)/750.0*100 as averageFillPercentage,response as averageCharacters from tblQuestionsMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|