944,073 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Unsolved
  • Views: 25125
  • ASP RSS
Feb 8th, 2005
0

problem for a simple asp.net query

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tishr is offline Offline
2 posts
since Feb 2005
Mar 8th, 2005
0

Re: problem for a simple asp.net query

Quote 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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pallab is offline Offline
1 posts
since Mar 2005
Mar 26th, 2007
0

Re: problem for a simple asp.net query

varchar has a maximum of 8000 bytes.

Another possible hack is

ASP Syntax (Toggle Plain Text)
  1. SELECT some_field FROM some_table
  2. WHERE (some_text_field LIKE 'VALUE')
Reputation Points: 18
Solved Threads: 6
Junior Poster in Training
lordspace is offline Offline
90 posts
since May 2006
Mar 26th, 2007
0

Re: problem for a simple asp.net query

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)

ASP Syntax (Toggle Plain Text)
  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
Reputation Points: 262
Solved Threads: 68
Veteran Poster
hollystyles is offline Offline
1,181 posts
since Feb 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: how to get network login user name
Next Thread in ASP Forum Timeline: How can i construct a database?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC