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 |
|
mayaaa
Starting Member
15 Posts |
Posted - 2009-04-01 : 02:25:03
|
| Hey all :)I'm a begginer at SQL so I would appreciate your help very much.This is my query:SELECT Z.* FROM (SELECT RowNumber = ROW_NUMBER() OVER (PARTITION BY c.Center ORDER BY [Date] DESC) ,QuarterDesc, MonthDesc, c.Center, count(X) as X, count(Y) as Y, count(*) as ALLfrom dbo.tablea a, dbo.tableb b, dbo.tablec cwhere a.[Date]=b.[Date]and b.Center=c.CenterGROUP BY QuarterDesc, MonthDesc, c.Center) ZWHERE Z.RowNumber <= 4order by Z.Center,Z.RowNumberI need to also be able to sum X and Y at the same query.Thank you very much for your assistance! |
|
|
ayamas
Aged Yak Warrior
552 Posts |
Posted - 2009-04-01 : 03:50:13
|
| Please post some sample data & desired output.Select Z.*,sum(X)... |
 |
|
|
|
|
|