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 |
|
ahmed123
Starting Member
2 Posts |
Posted - 2010-01-02 : 09:54:17
|
| Hello all membersI am biginner and need you help.I have two tables one named BDATA i whitch i am storeing business information and other tabel as Reviews to store the reviews on Businesses.Now i want to make a stored procedure that an argumet @ReviewCountand return me Data from BDate table with count of reviews that has more reviews than the @ReviewCountI am trying to create a stored procedure but getting the error "Invalid colum name ReviewCount"This is teh stored procedureCREATE PROCEDURE [dbo].[SB] ( @ReviewCount int )ASSELECT BDATA.data_id,(SELECT COUNT(*) AS Expr2 FROM Reviews WHERE (Reviews.ResID = BData.data_id)) AS ReviewCountFROM BDATA Where(ReviewCount>@ReviewCount) OR (@ReviewCount =0) |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-01-02 : 10:05:55
|
| [code]CREATE PROCEDURE [dbo].[SB]( @ReviewCount int)ASSELECT BDATA.data_id,r.ReviewsFROM BDATA JOIN (SELECT ResID,COUNT(Reviews.PK) AS ReviewsFROM ReviewsGROUP BY ResID) rON r.ResID = BData.data_idWHERE r.Reviews>@ReviewCountOR @ReviewCount =0[/code] |
 |
|
|
ahmed123
Starting Member
2 Posts |
Posted - 2010-01-04 : 00:29:43
|
| Thanks visakh |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-01-04 : 01:35:11
|
welcome |
 |
|
|
|
|
|