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 |
Girlnet
Yak Posting Veteran
77 Posts |
Posted - 2005-06-22 : 21:32:25
|
Please someone - help the boob - er . . noobThis gives me the correct results in Query Analyzer, but in multiple recordsets. And, of course, my datagrid only returns the first recordset.Basically, I need to get the @ROW which will change per row as the ParaID increments.It's basically getting the results from a survey (yes, no) per paragraph.ALTER PROCEDURE TAM_PROFILE_RESULTS(@PAGEID INT, @ROW FLOAT OUTPUT)ASDECLARE @X INTSET @X = 1WHILE @X < 7BEGINSELECT @ROW=COUNT(PAGEID) FROM TAM_P_Data where PageID=@PAGEID AND ParaID=@X --right herePRINT @ROWSELECT TOP 100 PERCENT dbo.TAM_Profiles.Profile, dbo.TAM_P_Data.PageID,dbo.TAM_P_Data.ParaID,((COUNT(dbo.TAM_P_Data.Choose)/@ROW)) AS TOTAL, dbo.TAM_P_Data.Choose, dbo.TAM_Profiles.IDFROM dbo.TAM_P_Data RIGHT OUTER JOINdbo.TAM_Profiles ON dbo.TAM_P_Data.ParaID = dbo.TAM_Profiles.ParaID AND dbo.TAM_P_Data.PageID = dbo.TAM_Profiles.PageIDGROUP BY dbo.TAM_Profiles.Profile, dbo.TAM_P_Data.PageID, dbo.TAM_P_Data.ParaID, dbo.TAM_P_Data.Choose, dbo.TAM_Profiles.IDHAVING (dbo.TAM_P_Data.Choose = 0) AND (dbo.TAM_P_Data.PageID = @PAGEID) and (dbo.TAM_P_Data.ParaID = @X)ORDER BY dbo.TAM_P_Data.PageIDSET @X = @X + 1print @XENDI know it's mangled crap, but I'm counting on the SQLTeam magic! I've been messing with this WAY too long! Is there a better WAY?? |
|
Girlnet
Yak Posting Veteran
77 Posts |
Posted - 2005-07-13 : 22:44:27
|
Well . . . I'm still struggling with this. Was wondering if anyone has a suggestion? Maybe a better way to accomplish? I have a survey which people vote on per paragraph. I'm trying to do a results page where I have to count the number of people that have voted on each paragraph (cause not every paragraph will get a vote) and how many agree with the statement. Then totalperparagraph/choose_yes = %agreeMake sense? A challenge for any guru!Thanks! |
|
|
Kristen
Test
22859 Posts |
Posted - 2005-07-14 : 01:25:00
|
Put SET NOCOUNT ONafter the "AS"(That doesn't solve your problem! but will prevent some unnecessary info. going to the client)Would this do any good?:Create a temporary table at the top of your SProc (perhaps including the value of @X in a column), INSERT each of your 7 SELECT statements into the temporary table, and then SELECT * FROM TemporaryTableat the endKristen |
|
|
Girlnet
Yak Posting Veteran
77 Posts |
Posted - 2005-07-14 : 08:34:17
|
Kristen - you are AWESOME! Thanks so much for replying. I think your suggestion just might work. I'll give it a shot and let you know. The temp table seems like a logical choice.BTW: My thoughts are with your country - please accept my sympathy for the loved ones lost. |
|
|
|
|
|
|
|