| Author |
Topic |
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2007-10-19 : 03:43:56
|
Hi,I have the following query, and I am getting the following error below. I designed this part a few months ago and have left and now I am just coming back to it. Not sure if this is possible but I swear it was working before, not sure if this is possible because of different data in the tables, regardless even if this is the case obviously my query needs help. Any help is much appreciated!! thanks once again! Server: Msg 4104, Level 16, State 1, Procedure select_videos_mostViewed, Line 8The multi-part identifier "vv.totalViews" could not be bound.CREATE PROCEDURE [dbo].[select_videos_mostViewed](@days int) AS SET NOCOUNT ON SELECT counterID, videoID, v.userID, caption, ratingID, UD.nameOnline,v.votes,v.points,v.videoDate,v.lengthSeconds, (select count(*) from tblVideoViews VV WHERE VV.userID = V.userID) as totalViewsFROM tblVideos V JOIN tblUserDetails UD on UD.userID = V.userIDWHERE status = 1ORDER BY vv.totalViews DESC |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-10-19 : 03:49:44
|
ORDER BY is NOT vv.totalViewsEither ORDER BY 11 (not recommended)or ORDER BY totalViews (without prefix) E 12°55'05.25"N 56°04'39.16" |
 |
|
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2007-10-19 : 03:58:09
|
| ahhh, nice and simple to fix.. thanks so much peso!! :) hope things are goin well up there in sweden :Dtill next time ;) |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-10-19 : 04:03:36
|
[code]CREATE PROCEDURE dbo.uspSelectVideosMostViewed( @Days int)ASSET NOCOUNT ON ;WITH Yak (CounterID, VideoID, UserID, CaptionID, RatingID, NameOnline, Votes, Points, VideoDate, LengthSeconds, TotalViews)AS ( SELECT v.CounterID, v.VideoID, v.UserID, v.CaptionID, v.RatingID, ud.NameOnline, v.Votes, v.Points, v.VideoDate, v.LengthSeconds, COUNT(vv.UserID) OVER (PARTITION BY v.UserID) AS TotalViews FROM tblVideos AS v INNER JOIN tblUserDetails AS ud ON ud.UserID = v.UserID LEFT JOIN tblVideoViews AS vv ON vv.UserID = v.UserID)SELECT CounterID, VideoID, UserID, CaptionID, RatingID, NameOnline, Votes, Points, VideoDate, LengthSeconds, TotalViewsFROM YakORDER BY TotalViews DESC[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-10-19 : 04:04:23
|
Don't forget to include the @Days parameter somewhere... E 12°55'05.25"N 56°04'39.16" |
 |
|
|
chrysler
Starting Member
3 Posts |
Posted - 2007-10-23 : 23:57:43
|
| hi i get the same error too.-------------CREATE PROCEDURE updateShelf -- Add the parameters for the stored procedure here @BookId varchar(50) = NULL, @ShelfName varchar(50) = NULLASBEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here UPDATE tblBook SET strShelfName = @BookId WHERE tblShelf.strBook = @ShelfName ENDGOThe multi-part identifier "tblShelf.strBook" could not be bound. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-10-24 : 00:00:32
|
You suppose to update tblBook or tblShelf table ?UPDATE tblBookSET strShelfName = @BookIdWHERE tblShelf.strBook = @ShelfName KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
chrysler
Starting Member
3 Posts |
Posted - 2007-10-24 : 00:07:54
|
oops. tblBookquote: Originally posted by khtan You suppose to update tblBook or tblShelf table ?UPDATE tblBookSET strShelfName = @BookIdWHERE tblShelf.strBook = @ShelfName KH[spoiler]Time is always against us[/spoiler]
|
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-10-24 : 00:12:44
|
quote: Originally posted by chrysler oops. tblBook
Sorry, don't understand your reply. maybe you should use the following update syntax. It is clearer.UPDATE aSET strShelfName = @BookIdFROM tblBook aWHERE a.strBook = @ShelfName KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
chrysler
Starting Member
3 Posts |
Posted - 2007-10-24 : 03:43:16
|
| may i ask if there are more than 1 value in an attribute(strbook FROM tblRack) that is one of my conditions, how do i go about doing it?my strBook FROM tblRack consists of more than one value, it's a string of values("value1,value2,value3") how do i split it out to compare with tblBook.strBook.AND ALSO. i get errors for my "tblShelf.strShelfName"(The multi-part identifier "tblShelf.strShelfName" could not be bound.)CREATE PROCEDURE updateBook-- Add the parameters for the stored procedure hereASBEGIN-- SET NOCOUNT ON added to prevent extra result sets from-- interfering with SELECT statements.SET NOCOUNT ON;-- Insert statements for procedure hereUPDATE tblBookSET tblBook.strShelfName = tblShelf.strShelfNameWHERE tblBook.strBook = (SELECT strBook FROM tblShelf)ENDGO |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-10-24 : 03:45:31
|
Don't hijack topics.Start your own. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|