problem for a simple asp.net query

Reply

Join Date: Feb 2005
Posts: 2
Reputation: tishr is an unknown quantity at this point 
Solved Threads: 0
tishr tishr is offline Offline
Newbie Poster

problem for a simple asp.net query

 
0
  #1
Feb 8th, 2005
could any one plz help me for this query. i have tried a lot but only the first one is working. see my code:

(1)

CommandText = _
"SELECT sr.ResponseAnswerID, count(sr.RespondantID) from SURVEY_RESPONSE sr INNER JOIN ANSWER a on " _
& "sr.ResponseAnswerID=a.AnswerID where a.QuestionID= 284 " _
& "group by sr.ResponseAnswerID"


(2)
CommandText = _
"SELECT a.AnswerDescription, count(sr.RespondantID) from SURVEY_RESPONSE sr INNER JOIN ANSWER a on " _
& "sr.ResponseAnswerID=a.AnswerID where a.QuestionID= 284 " _
& "group by a.AnswerDescription"

------
for the first one it is working fine but displaying only its id. what i want is AnswerDescription instead of ResponseAnswerID.

the error for (2) is
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.


i have tried a lot, using select in another select statement, having into, like.... but none is working

hope to have a quick response. thanks

antish
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 1
Reputation: pallab is an unknown quantity at this point 
Solved Threads: 0
pallab pallab is offline Offline
Newbie Poster

Re: problem for a simple asp.net query

 
0
  #2
Mar 8th, 2005
Originally Posted by tishr
could any one plz help me for this query. i have tried a lot but only the first one is working. see my code:

(1)

CommandText = _
"SELECT sr.ResponseAnswerID, count(sr.RespondantID) from SURVEY_RESPONSE sr INNER JOIN ANSWER a on " _
& "sr.ResponseAnswerID=a.AnswerID where a.QuestionID= 284 " _
& "group by sr.ResponseAnswerID"


(2)
CommandText = _
"SELECT a.AnswerDescription, count(sr.RespondantID) from SURVEY_RESPONSE sr INNER JOIN ANSWER a on " _
& "sr.ResponseAnswerID=a.AnswerID where a.QuestionID= 284 " _
& "group by a.AnswerDescription"

------
for the first one it is working fine but displaying only its id. what i want is AnswerDescription instead of ResponseAnswerID.

the error for (2) is
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.


i have tried a lot, using select in another select statement, having into, like.... but none is working

hope to have a quick response. thanks

antish
Hello,

You have any field in either table which is having a data type of text or ntext or image. If you used text or ntext field, please change the datatype to varchar and then try the query again.

All the best

Pallab
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 66
Reputation: lordspace is an unknown quantity at this point 
Solved Threads: 4
lordspace's Avatar
lordspace lordspace is offline Offline
Junior Poster in Training

Re: problem for a simple asp.net query

 
0
  #3
Mar 26th, 2007
varchar has a maximum of 8000 bytes.

Another possible hack is

  1. SELECT some_field FROM some_table
  2. WHERE (some_text_field LIKE 'VALUE')
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 1,181
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Solved Threads: 67
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: problem for a simple asp.net query

 
0
  #4
Mar 26th, 2007
Do the aggregation in a subquery, then join on to the answer table from there to pull the description (Sql Datatypes text ntext and image can't be used in GROUP BY clauses)

  1. select
  2. oa.AnswerDescription,
  3. srCount
  4. from
  5. (
  6. SELECT
  7. sr.ResponseAnswerID,
  8. count(sr.RespondantID) as srCount
  9. from
  10. SURVEY_RESPONSE sr
  11. INNER JOIN ANSWER a on sr.ResponseAnswerID=a.AnswerID
  12. where a.QuestionID= 284
  13. group by
  14. sr.ResponseAnswerID
  15. ) sub
  16. join ANSWER oa on sub.ResponseAnswerID = oa.AnswerID
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC