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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Reg. Query Modification

Author  Topic 

dhinasql
Posting Yak Master

195 Posts

Posted - 2009-03-09 : 05:20:24
Dear Friends,

I need your help in modifying query,

Please find the below query

SELECT r.ID, r.Title,r.Text,r.Description,r.picture as picture,r.EntryName,r.UserName,r.firstname FROM (SELECT ROW_NUMBER() OVER (ORDER BY ID DESC) AS Seq2,t.ID, t.Title,t.Text,t.Description,t.picture as picture,t.EntryName,t.UserName,t.firstname FROM (Select ROW_NUMBER() OVER(PARTITION BY con.UserName ORDER BY c.ID DESC) AS Seq1, c.ID, c.Title,c.Text,c.Description,u.picture as picture,c.EntryName,con.UserName,u.firstname,userid from dbo.wlbuserfls u inner join subtext_Config con on u.username = con.UserName inner join subtext_Content as c on con.BlogId = c.BlogId where u.picture !='images/defaultphoto.gif') t WHERE t.Seq1=1 )r WHERE Seq2<=5

Now it is displaying the

ID Title Text Description picture EntryName UserName
firstname

I want to fetch userid and display with this fields , userid is available in wlbuserfls

Please modify the query, thanks in advance

matty
Posting Yak Master

161 Posts

Posted - 2009-03-09 : 05:38:48
SELECT r.ID, r.Title,r.Text,r.Description,r.picture as picture,r.EntryName,r.UserName,r.firstname,r.userid
FROM
(
SELECT ROW_NUMBER() OVER (ORDER BY ID DESC) AS Seq2,t.ID, t.Title,t.Text,t.Description,t.picture as picture,
t.EntryName,t.UserName,t.firstname,t.userid
FROM
(
Select ROW_NUMBER() OVER(PARTITION BY con.UserName ORDER BY c.ID DESC) AS Seq1, c.ID, c.Title,c.Text,
c.Description,u.picture as picture,c.EntryName,con.UserName,u.firstname,userid
from dbo.wlbuserfls u inner join subtext_Config con on u.username = con.UserName
inner join subtext_Content as c on con.BlogId = c.BlogId
where u.picture !='images/defaultphoto.gif'
) t
WHERE t.Seq1=1
)r
WHERE Seq2<=5
Go to Top of Page
   

- Advertisement -