Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Simple query having a rate over the medium

$
0
0

Hi guys, I'm tryng to create a simple query who return me the employee with the salary over the average. Using adventure works like sample:

select firstname, lastname, avg(baserate) as avgbaserate, baserate from dimemployee group by DepartmentName having baserate >avg(baserate) 

I've tried the query above. Having an average I want know who is over the average and who is under. I could create two stored prodecure, one who give me the average and one who select the results. But I'm wondering how I can extract the data using a simple query. Any advice? Thank you a lot.  


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>