codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  sql query  Jyotsna at 08:43 on Friday, January 16, 2009
 

I am running a market survey and all the survey data is saved in the database ,i need a query for counting the number of rows in which option "1" is selected for question "1" , option "2" for question "1" and so on for all questions and options....i need to specify few conditions here ,i have to match distinct ID's of 3 database tables and display the result for each particular ID...i have written sample query but its not showing results with value as'0'

select opt1.question_no, opt_num1, opt_num2

from

(select question_no, count(option_number) opt_num1, stm.survey_id survey_id

from SURVEY_TXN_DATA std

, survey_txn_master stm,survey_master sm

where stm.survey_id = sm.survey_id

and stm.survey_txn_master_rowid = std.survey_txn_master_rowid

and stm.survey_id = 6

and option_number = 1

group by question_no,stm.survey_id) as opt1,

(select question_no, count(option_number) opt_num2, stm.survey_id survey_id

from SURVEY_TXN_DATA std

, survey_txn_master stm,survey_master sm

where stm.survey_id = sm.survey_id

and stm.survey_txn_master_rowid = std.survey_txn_master_rowid

and stm.survey_id = 6

and option_number = 2

group by question_no,stm.survey_id) as opt2

where opt1.survey_id = opt2.survey_id

and opt1.question_no = opt2.question_no

group by opt1.question_no ,opt_num1

, opt_num2










CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Animation works on IE but not on Firefox
•  Re: Add an OnChange event to an ASP page
•  Re: combined 3 functions that do the same thing
•  Button link to excel
•  parser project needs c++ programmer
•  Simple Thumbnail Solution
•  Re: hex code of a number
•  sql query
•  Re: number of regex match


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2009