Click here to Skip to main content
15,900,378 members
Home / Discussions / Database
   

Database

 
GeneralRe: Issue while updating the DateTime field thru VB.NET Pin
hariram2820-Jun-08 12:37
hariram2820-Jun-08 12:37 
GeneralRe: Issue while updating the DateTime field thru VB.NET Pin
Ashfield21-Jun-08 7:28
Ashfield21-Jun-08 7:28 
QuestionGenerating XML Schema of SQL Server 2005 Database Pin
Rocky#20-Jun-08 3:13
Rocky#20-Jun-08 3:13 
QuestionMySql and DbCommand [modified] Pin
gandalf_le_blanc20-Jun-08 3:10
gandalf_le_blanc20-Jun-08 3:10 
Questionexception handling sql server 2005 Pin
Learner52020-Jun-08 2:20
Learner52020-Jun-08 2:20 
AnswerRe: exception handling sql server 2005 Pin
Hesham Amin20-Jun-08 6:01
Hesham Amin20-Jun-08 6:01 
GeneralRe: exception handling sql server 2005 Pin
Learner52020-Jun-08 6:17
Learner52020-Jun-08 6:17 
QuestionChange data arrangement Pin
SomeGuyThatIsMe20-Jun-08 1:28
SomeGuyThatIsMe20-Jun-08 1:28 
Hey, i have a table with several columns Q1 to Q9, ID, datetime, ID is the same for a given group of data. Each column Q1 to Q9 can have up to 12(-2 - 9) values in it, and 10 to hundreds of thousands of rows per ID(dont ask it does make sense i just dont feel like explaining it). and i'm trying to make a report in CR 2008 but i cant get it generate graphs of all the occurances of values in all 9 columns w/out 9 graphs. so the only solution i can think of is to change the columns in to rows and make the differnt possible values columns like
Question -2s -1s 0s 1s 2s ...9s
Q1 3 0 0 2 1 (a count of the number of times each value appears)

i'm managed it with this, long but simple, and suprisingly speedy

SELECT 'Q1' AS Question,
       COUNT(Q1) - COUNT(NULLIF(Q1,-2)) AS '-2s',
       COUNT(Q1) - COUNT(NULLIF(Q1,-1)) AS '-1s',
       COUNT(Q1) - COUNT(NULLIF(Q1,0))  AS '0s',
       COUNT(Q1) - COUNT(NULLIF(Q1,1))  AS '1s',
       COUNT(Q1) - COUNT(NULLIF(Q1,2))  AS '2s',
       COUNT(Q1) - COUNT(NULLIF(Q1,3))  AS '3s',
       COUNT(Q1) - COUNT(NULLIF(Q1,4))  AS '4s',
       COUNT(Q1) - COUNT(NULLIF(Q1,5))  AS '5s',
       COUNT(Q1) - COUNT(NULLIF(Q1,6))  AS '6s',
       COUNT(Q1) - COUNT(NULLIF(Q1,7))  AS '7s',
       COUNT(Q1) - COUNT(NULLIF(Q1,8))  AS '8s',
       COUNT(Q1) - COUNT(NULLIF(Q1,9))  AS '9s'
  FROM table
UNION
   -- repeat query/union for all 9 Q columns


personally i think this way sucks, and there has to be a better one, but i'm at a loss as to what it is. Any help would be appreciated, oh and because i'll know very little about the data before running the report and it will be accessed from a web app i dont think a temp table would work very well either, and it wouldnt be as simplistic.

Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

QuestionRecommendation for SQL Server book Pin
Baconbutty19-Jun-08 22:48
Baconbutty19-Jun-08 22:48 
AnswerRe: Recommendation for SQL Server book Pin
Alsvha19-Jun-08 23:50
Alsvha19-Jun-08 23:50 
QuestionAutomatic Transaction between MySQL and MSMQ Pin
jmohan19-Jun-08 22:02
jmohan19-Jun-08 22:02 
GeneralOLAP Cube for Sql server 2005 Pin
jagmit2019-Jun-08 20:45
jagmit2019-Jun-08 20:45 
QuestionNormalization Pin
Pankaj Garg19-Jun-08 19:25
Pankaj Garg19-Jun-08 19:25 
AnswerRe: Normalization Pin
Ashfield19-Jun-08 21:05
Ashfield19-Jun-08 21:05 
AnswerRe: Normalization Pin
CPallini19-Jun-08 22:03
mveCPallini19-Jun-08 22:03 
NewsRe: Normalization Pin
Pankaj Garg19-Jun-08 23:26
Pankaj Garg19-Jun-08 23:26 
GeneralRe: Normalization Pin
CPallini20-Jun-08 0:00
mveCPallini20-Jun-08 0:00 
GeneralRe: Normalization Pin
Jerry Hammond21-Jun-08 7:44
Jerry Hammond21-Jun-08 7:44 
GeneralRe: Normalization Pin
CPallini22-Jun-08 0:44
mveCPallini22-Jun-08 0:44 
QuestionProblem in Query Pin
garga119-Jun-08 19:06
garga119-Jun-08 19:06 
AnswerRe: Problem in Query Pin
Marek Grzenkowicz19-Jun-08 21:31
Marek Grzenkowicz19-Jun-08 21:31 
AnswerRe: Problem in Query Pin
Anurag Gandhi19-Jun-08 22:00
professionalAnurag Gandhi19-Jun-08 22:00 
GeneralRe: Problem in Query Pin
garga120-Jun-08 1:39
garga120-Jun-08 1:39 
AnswerRe: Problem in Query Pin
Ashfield20-Jun-08 0:58
Ashfield20-Jun-08 0:58 
AnswerRe: Problem in Query Pin
Niraj_Silver26-Jun-08 0:06
Niraj_Silver26-Jun-08 0:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.