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 |
|
a_Qaddomi
Starting Member
6 Posts |
Posted - 2011-11-20 : 06:22:09
|
| Hi there ,I have a question table contains QuiestionID QuestionText EstimatedTime----------- ------------ ------------- 1------------------A-------------5 2------------------B-------------4 3------------------C-------------6 4------------------D-------------3I need a select statement retrieve random questions with estimated time 9 for example. I tried this statement but it is not working ..select QuestionID,sum(EstimatedTime) from question group by QuestionID having sum(EstimatedTime)=9.Thanks for your time |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-20 : 06:28:00
|
| [code]select top 10 * from table where EstimatedTime=9 order by newid() [/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
a_Qaddomi
Starting Member
6 Posts |
Posted - 2011-11-20 : 06:31:03
|
| No I need sum of estimated time of retrieved questions is 9 .. so you need to use the SUM function. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-20 : 06:32:46
|
quote: Originally posted by a_Qaddomi No I need sum of estimated time of retrieved questions is 9 .. so you need to use the SUM function.
hmm? what does that mean? so can you show what would be output from data above?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
a_Qaddomi
Starting Member
6 Posts |
Posted - 2011-11-20 : 06:35:28
|
| ok .. the result would be for example QuestionID -->1 & 2 OR 3 & 4 because sum of this questions' estimated time is 9 |
 |
|
|
a_Qaddomi
Starting Member
6 Posts |
Posted - 2011-11-20 : 10:15:02
|
| No Body can help ?? |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|