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 |
|
mcupryk
Yak Posting Veteran
91 Posts |
Posted - 2011-01-25 : 18:12:49
|
| ALTERPROCEDURE [dbo].[prc_ProfileViews_SelectByUserName](@ViewedUsernameID int,@FromDate DATETIME = NULL )ASSELECTTOP 100 XXXXX.ViewedUserNameID as ViewedUserNameID, ---> need to join this with table PK tbl_profile on ProfileID = PK ViewedUserNameID on tbl_ProfileViewsa.ProfileID as ProfileID,a.UserName as UserName,a.FirstName as FirstName,a.LastName as LastName,a.HeadLine as HeadLine,a.EmailAddress as EmailAddress,a.GenderID as Gender,b.Gender as GenderName,a.SeekingID as Seeking,c.Seeking as SeekingName,a.SearchAgeStartID as StartAge, --------------------------------------------------------------------------------------------ALTER PROCEDURE [dbo].[prc_ProfileViews_SelectByUserName]( @ViewedUsernameID int, @FromDate DATETIME = NULL)ASSELECT TOP 100A.[UserNameID] as ViewerUserNameID, ----- table tbl_ProfileViewsA.[ViewUserNameID] as ViewedUserNameID, ----- table tbl_ProfileViewsA.[TimeStamp] as ViewedDate, ----- table tbl_ProfileViewsB.[PhotoID], ----- table tbl_PhotosB.[ProfileID], ----- table tbl_PhotosB.[p_Primary] ----- table tbl_PhotosFROM tbl_ProfileViews A INNER JOIN tbl_Photos B ON A.UserNameID = B.ProfileIDWHERE A.ViewUserNameID = @ViewedUsernameID AND B.[p_Primary] = '1'AND A.[TimeStamp] = (SELECT MAX(C.[TimeStamp]) from tbl_ProfileViews C Where C.ViewUserNameID = @ViewedUsernameID) ORDER BY A.[TimeStamp] DESCNeed to join tbl_Profiles to getXXXXX.ViewedUserNameID as ViewedUserNameID, ---> need to join this with table PK tbl_profile on ProfileID = PK ViewedUserNameID on tbl_ProfileViewsa.ProfileID as ProfileID,a.UserName as UserName,a.FirstName as FirstName,a.LastName as LastName,a.HeadLine as HeadLine,a.EmailAddress as EmailAddress,a.GenderID as Gender,b.Gender as GenderName,a.SeekingID as Seeking,c.Seeking as SeekingName,a.SearchAgeStartID as StartAge,Any help would be awesome. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-01-26 : 10:57:18
|
| sorry very difficult to determine from query what you're looking at. please post some sample data along with table strucutures and then explain what you want------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|