Click here to Skip to main content
12,293,515 members (64,339 online)
   

Database

 
AnswerRe: Cumulative addition among views. Pin
Mycroft Holmes12-Aug-12 18:29
memberMycroft Holmes12-Aug-12 18:29 
QuestionHelp with Decimal Roundings Pin
Vuyiswa Maseko12-Aug-12 0:51
memberVuyiswa Maseko12-Aug-12 0:51 
AnswerRe: Help with Decimal Roundings Pin
Eddy Vluggen12-Aug-12 1:10
memberEddy Vluggen12-Aug-12 1:10 
GeneralRe: Help with Decimal Roundings Pin
Vuyiswa Maseko12-Aug-12 2:01
memberVuyiswa Maseko12-Aug-12 2:01 
AnswerRe: Help with Decimal Roundings Pin
Niladri_Biswas21-Aug-12 22:39
mvpNiladri_Biswas21-Aug-12 22:39 
QuestionHow to convert Physical XML files into Sqlserver Tables? Pin
Member 400654610-Aug-12 13:10
memberMember 400654610-Aug-12 13:10 
AnswerRe: How to convert Physical XML files into Sqlserver Tables? Pin
PIEBALDconsult10-Aug-12 13:32
memberPIEBALDconsult10-Aug-12 13:32 
AnswerRe: How to convert Physical XML files into Sqlserver Tables? Pin
Eddy Vluggen10-Aug-12 23:52
memberEddy Vluggen10-Aug-12 23:52 
QuestionHow do you use the AVG api in sql to manage grouped output? Pin
Xarzu10-Aug-12 13:04
memberXarzu10-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
memberPaul 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
memberXarzu11-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
memberPaul 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
memberEddy 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
mvpNiladri_Biswas21-Aug-12 22:51 
All Version of Sql server

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

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
memberJörgen Andersson10-Aug-12 9:57 
AnswerRe: How to store a standard selection? Pin
mark merrens10-Aug-12 10:02
membermark merrens10-Aug-12 10:02 
GeneralRe: How to store a standard selection? Pin
Jörgen Andersson10-Aug-12 10:09
memberJörgen Andersson10-Aug-12 10:09 
GeneralRe: How to store a standard selection? Pin
mark merrens10-Aug-12 10:41
membermark merrens10-Aug-12 10:41 
AnswerRe: How to store a standard selection? Pin
Eddy Vluggen10-Aug-12 10:11
memberEddy Vluggen10-Aug-12 10:11 
GeneralRe: How to store a standard selection? Pin
Jörgen Andersson10-Aug-12 10:31
memberJörgen Andersson10-Aug-12 10:31 
QuestionDatabase status check and report Pin
leketekoa10-Aug-12 4:12
memberleketekoa10-Aug-12 4:12 
AnswerRe: Database status check and report Pin
David Mujica10-Aug-12 5:10
memberDavid Mujica10-Aug-12 5:10 
GeneralRe: Database status check and report Pin
leketekoa13-Aug-12 4:30
memberleketekoa13-Aug-12 4:30 
AnswerRe: Database status check and report Pin
jschell10-Aug-12 12:46
memberjschell10-Aug-12 12:46 
QuestionSymantec Q&A File Conversion Pin
snowman539-Aug-12 12:54
membersnowman539-Aug-12 12:54 
AnswerRe: Symantec Q&A File Conversion Pin
Eddy Vluggen9-Aug-12 22:21
memberEddy Vluggen9-Aug-12 22:21 
GeneralRe: Symantec Q&A File Conversion Pin
snowman5310-Aug-12 11:51
membersnowman5310-Aug-12 11:51 
GeneralRe: Symantec Q&A File Conversion Pin
Eddy Vluggen10-Aug-12 22:13
memberEddy Vluggen10-Aug-12 22:13 
AnswerRe: Symantec Q&A File Conversion Pin
Mycroft Holmes12-Aug-12 18:18
memberMycroft Holmes12-Aug-12 18:18 
GeneralRe: Symantec Q&A File Conversion Pin
snowman5313-Aug-12 6:36
membersnowman5313-Aug-12 6:36 
QuestionUsername/password protected database Pin
Kujtim Hyseni7-Aug-12 10:10
memberKujtim Hyseni7-Aug-12 10:10 
AnswerRe: Username/password protected database Pin
Mycroft Holmes7-Aug-12 12:49
memberMycroft Holmes7-Aug-12 12:49 
AnswerRe: Username/password protected database Pin
Michael Aimakhede9-Aug-12 19:42
memberMichael Aimakhede9-Aug-12 19:42 
GeneralRe: Username/password protected database Pin
Eddy Vluggen10-Aug-12 6:03
memberEddy Vluggen10-Aug-12 6:03 
QuestionGet records having different data in 2 rows Pin
Vipul Mehta5-Aug-12 19:14
memberVipul Mehta5-Aug-12 19:14 
AnswerRe: Get records having different data in 2 rows Pin
Vipul Mehta5-Aug-12 21:03
memberVipul Mehta5-Aug-12 21:03 
AnswerRe: Get records having different data in 2 rows Pin
JammoD876-Aug-12 0:40
memberJammoD876-Aug-12 0:40 
GeneralRe: Get records having different data in 2 rows Pin
Bernhard Hiller6-Aug-12 21:56
memberBernhard Hiller6-Aug-12 21:56 
GeneralRe: Get records having different data in 2 rows Pin
JammoD876-Aug-12 22:18
memberJammoD876-Aug-12 22:18 
AnswerRe: Get records having different data in 2 rows Pin
Arun_linux6-Aug-12 3:29
groupArun_linux6-Aug-12 3:29 
GeneralRe: Get records having different data in 2 rows Pin
Mycroft Holmes6-Aug-12 12:42
memberMycroft Holmes6-Aug-12 12:42 
GeneralRe: Get records having different data in 2 rows Pin
Bernhard Hiller6-Aug-12 21:58
memberBernhard Hiller6-Aug-12 21:58 
GeneralRe: Get records having different data in 2 rows Pin
Mycroft Holmes6-Aug-12 23:39
memberMycroft Holmes6-Aug-12 23:39 
GeneralRe: Get records having different data in 2 rows Pin
Simon_Whale6-Aug-12 22:21
memberSimon_Whale6-Aug-12 22:21 
AnswerRe: Get records having different data in 2 rows Pin
Bernhard Hiller6-Aug-12 21:45
memberBernhard Hiller6-Aug-12 21:45 
AnswerRe: Get records having different data in 2 rows Pin
Niju114-Aug-12 1:15
memberNiju114-Aug-12 1:15 
AnswerRe: Get records having different data in 2 rows Pin
Karthik_J, Coimbatore29-Aug-12 0:02
memberKarthik_J, Coimbatore29-Aug-12 0:02 
GeneralInsert Function Inserts Only Parameternames Pin
ASPnoob3-Aug-12 10:15
memberASPnoob3-Aug-12 10:15 
GeneralRe: Insert Function Inserts Only Parameternames Pin
mark merrens3-Aug-12 10:23
membermark merrens3-Aug-12 10:23 
GeneralRe: Insert Function Inserts Only Parameternames Pin
ASPnoob3-Aug-12 10:49
memberASPnoob3-Aug-12 10:49 

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.


Advertise | Privacy | Mobile
Web02 | 2.8.160518.1 | Last Updated 23 May 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid