Click here to Skip to main content
15,867,308 members
Home / Discussions / Database
   

Database

 
AnswerRe: How to convert Physical XML files into Sqlserver Tables? Pin
PIEBALDconsult10-Aug-12 13:32
mvePIEBALDconsult10-Aug-12 13:32 
AnswerRe: How to convert Physical XML files into Sqlserver Tables? Pin
Eddy Vluggen10-Aug-12 23:52
professionalEddy Vluggen10-Aug-12 23:52 
QuestionHow do you use the AVG api in sql to manage grouped output? Pin
Xarzu10-Aug-12 13:04
Xarzu10-Aug-12 13:04 
AnswerRe: How do you use the AVG api in sql to manage grouped output? Pin
Paul Conrad10-Aug-12 20:18
professionalPaul Conrad10-Aug-12 20:18 
GeneralRe: How do you use the AVG api in sql to manage grouped output? Pin
Xarzu11-Aug-12 13:30
Xarzu11-Aug-12 13:30 
AnswerRe: How do you use the AVG api in sql to manage grouped output? Pin
Paul Conrad11-Aug-12 13:32
professionalPaul Conrad11-Aug-12 13:32 
AnswerRe: How do you use the AVG api in sql to manage grouped output? Pin
Eddy Vluggen10-Aug-12 22:17
professionalEddy Vluggen10-Aug-12 22:17 
AnswerRe: How do you use the AVG api in sql to manage grouped output? Pin
Niladri_Biswas21-Aug-12 22:51
Niladri_Biswas21-Aug-12 22:51 
All Version of Sql server

SQL
Select City, AVG(Salary) AS Salary
FROM @t
Group By City
Order By City DESC


This can also be done by treating AVG function as Analytical function which is available since SQL Server 2005

SQL
Select City,Salary From
(
    Select
        Rn = Row_Number() Over(PARTITION BY City Order By (Select 1))
        ,City
        ,AVG(Salary) OVER(PARTITION BY City) AS Salary
    From @t) X
Where X.Rn = 1
Order By City DESC


The answer for both the cases

City Salary
Seattle 20000
Redmond 30000
Niladri Biswas
(Code Project MVP 2012)

QuestionHow to store a standard selection? Pin
Jörgen Andersson10-Aug-12 9:57
professionalJörgen Andersson10-Aug-12 9:57 
AnswerRe: How to store a standard selection? Pin
R. Giskard Reventlov10-Aug-12 10:02
R. Giskard Reventlov10-Aug-12 10:02 
GeneralRe: How to store a standard selection? Pin
Jörgen Andersson10-Aug-12 10:09
professionalJörgen Andersson10-Aug-12 10:09 
GeneralRe: How to store a standard selection? Pin
R. Giskard Reventlov10-Aug-12 10:41
R. Giskard Reventlov10-Aug-12 10:41 
AnswerRe: How to store a standard selection? Pin
Eddy Vluggen10-Aug-12 10:11
professionalEddy Vluggen10-Aug-12 10:11 
GeneralRe: How to store a standard selection? Pin
Jörgen Andersson10-Aug-12 10:31
professionalJörgen Andersson10-Aug-12 10:31 
QuestionDatabase status check and report Pin
leketekoa10-Aug-12 4:12
leketekoa10-Aug-12 4:12 
AnswerRe: Database status check and report Pin
David Mujica10-Aug-12 5:10
David Mujica10-Aug-12 5:10 
GeneralRe: Database status check and report Pin
leketekoa13-Aug-12 4:30
leketekoa13-Aug-12 4:30 
AnswerRe: Database status check and report Pin
jschell10-Aug-12 12:46
jschell10-Aug-12 12:46 
QuestionSymantec Q&A File Conversion Pin
snowman539-Aug-12 12:54
snowman539-Aug-12 12:54 
AnswerRe: Symantec Q&A File Conversion Pin
Eddy Vluggen9-Aug-12 22:21
professionalEddy Vluggen9-Aug-12 22:21 
GeneralRe: Symantec Q&A File Conversion Pin
snowman5310-Aug-12 11:51
snowman5310-Aug-12 11:51 
GeneralRe: Symantec Q&A File Conversion Pin
Eddy Vluggen10-Aug-12 22:13
professionalEddy Vluggen10-Aug-12 22:13 
AnswerRe: Symantec Q&A File Conversion Pin
Mycroft Holmes12-Aug-12 18:18
professionalMycroft Holmes12-Aug-12 18:18 
GeneralRe: Symantec Q&A File Conversion Pin
snowman5313-Aug-12 6:36
snowman5313-Aug-12 6:36 
QuestionUsername/password protected database Pin
Kujtim Hyseni7-Aug-12 10:10
Kujtim Hyseni7-Aug-12 10:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.