May 2, 2011 at 2:13 pm
top clause...where does it go and how?lol
May 2, 2011 at 2:17 pm
normanshongo2003 (5/2/2011)
top clause...where does it go and how?lol
if "in the query via your keyboard" isn't enough explanation you might have to look it up. I have no problem helping you but I am not being paid nor am I a tutor. Remember google is your friend.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
May 2, 2011 at 2:19 pm
ok...sorry...
May 2, 2011 at 2:20 pm
select d.Department_No,top 1*(AVG(Annual_Salary)) AS Lowest_Avg_Annual_Salary
from Departments d
inner join
Employees e
on d.Department_No=e.Department_No
group by D.Department_No
order by AVG (annual_salary)
May 2, 2011 at 2:23 pm
normanshongo2003 (5/2/2011)
select d.Department_No,top 1*(AVG(Annual_Salary)) AS Lowest_Avg_Annual_Salaryfrom Departments d
inner join
Employees e
on d.Department_No=e.Department_No
group by D.Department_No
order by AVG (annual_salary)
Does that work?
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
May 2, 2011 at 2:25 pm
Msg 156, Level 15, State 1, Line 90
Incorrect syntax near the keyword 'top'.
May 2, 2011 at 2:32 pm
no good
May 2, 2011 at 2:33 pm
In addition to Google, Books Online (BoL) is also your friend. You can access it by press the f1 function key while in SSMS. Search for SELECT.
May 2, 2011 at 2:38 pm
/soapbox on
I feel bad for you but you are going to have to look up stuff. There are 2 choices for you. You can either go to an online forum and get spoon fed the results so you learn nothing or you can find people like the ones on here that are willing and able to help you help yourself but ultimately you have put in the effort. Dig in, get your hands dirty. It is the only way you will learn this stuff and you might just find a passion that you never knew you had.
/soapbox off
Here is the basic syntax for TOP
SELECT TOP number|percent column_name(s)
FROM table_name
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
May 2, 2011 at 2:46 pm
You may also want to invest in an introductory book on T-SQL. I don't have any titles handy as I have been working with T-SQL for over 12 years. Go to you local bookstore and see what is there. I'm sure some one here may also suggest a good book or two as well.
May 2, 2011 at 2:49 pm
select top 1 d.Department_No,(AVG(Annual_Salary)) AS Lowest_Avg_Annual_Salary
from Departments d
inner join
Employees e
on d.Department_No=e.Department_No
group by D.Department_No
order by AVG (annual_salary)
hiya, i get it with this query.but what if i had a list of 100 departments and needed the lowest?..
May 2, 2011 at 2:50 pm
Department_NoLowest_Avg_Annual_Salary
1908792.307692
May 2, 2011 at 2:51 pm
normanshongo2003 (5/2/2011)
select top 1 d.Department_No,(AVG(Annual_Salary)) AS Lowest_Avg_Annual_Salaryfrom Departments d
inner join
Employees e
on d.Department_No=e.Department_No
group by D.Department_No
order by AVG (annual_salary)
hiya, i get it with this query.but what if i had a list of 100 departments and needed the lowest?..
There you go!!!!
Well does it really matter how many departments there are??? Doesn't this return the lowest???
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
May 2, 2011 at 2:53 pm
thanks sean so much pal .....
May 2, 2011 at 2:55 pm
happy to help. Hope you walked away learning something. Good luck on your test.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 15 posts - 31 through 45 (of 46 total)
You must be logged in to reply to this topic. Login to reply