November 9, 2010 at 12:12 pm
Craig Farrell (11/9/2010)
Sachin.Nandanwar (11/9/2010)
rko.37gags (11/9/2010)
i attached the excel fileNow that's better.
Below is your query.
select * from
(
select *,row_number()over(partition by employeeid order by salary desc)rid from salary
)T where rid<=2
You're nicer than I am, Sachin. I fear I would be forced to Blah Blah some more.
😀
--------------------------------------------------------------------------------------------------
I am just an another naive wannabe DBA trying to learn SQL Server
November 9, 2010 at 12:13 pm
Does your book tell you what version of SQL Server? If it's SQL 2000, the answer will be different.
Scott Pletcher, SQL Server MVP 2008-2010
November 9, 2010 at 12:15 pm
rko.37gags (11/9/2010)
Thanks for ur reply....Some doubts..select * from
(
select *,row_number()over(partition by employeeid order by salary desc)rid from salary
)T where rid<=2
what is rid and T
You really wanna know?
I thought you would rather be happy with a spoon fed answer.
--------------------------------------------------------------------------------------------------
I am just an another naive wannabe DBA trying to learn SQL Server
November 9, 2010 at 12:20 pm
Come on Dude....Just tell me.....what is "T" in that query
November 9, 2010 at 12:26 pm
rko.37gags (11/9/2010)
Come on Dude....Just tell me.....what is "T" in that query
This is something called as a "derived table" which encapsulates the result of a SELECT statement in the FROM clause to another SELECT statement.
http://www.mssqltips.com/tip.asp?tip=1042
--------------------------------------------------------------------------------------------------
I am just an another naive wannabe DBA trying to learn SQL Server
November 9, 2010 at 12:30 pm
Also my solution will work for SQL 2005 and later.
I am assuming you are using a version greater than SQL 2000 since you have posted your question in SQL 2005 forum.With any version less than 2005 the query will be a lot different.
--------------------------------------------------------------------------------------------------
I am just an another naive wannabe DBA trying to learn SQL Server
November 9, 2010 at 12:39 pm
For the curious, question is from here:
www.scribd.com/doc/40561966/sql-Test.
Blocked by websense, I'm assuming it's a historical question/quiz.
How to find it?
So, the answer they really want is:
Blah bla bla, blah blah. Blah BLAH blah blah... blah blah!
SELECT BLAH 2 BLAH FROM BLAH.BLAH.BLAH AS blah group by blah.blah having blah.blah >= 2.
Good Luck.
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
November 9, 2010 at 12:47 pm
rko.37gags (11/9/2010)
Plz post me the query.....i didnt understand ur "Blah Blah"
The troll speaketh!!
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
November 9, 2010 at 12:55 pm
rko.37gags (11/9/2010)
what is rid and T
They are aliases. One is for a table, one for a column.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
November 9, 2010 at 1:09 pm
I thought maybe they stood for no chance this person is qualified for the "DB_Developer" position and should therefore keep looking for the entry level position. 😛 You will not be successful in a new job that you are under qualified for. What are you going to do when asked to something as simple as this at work and you have no idea how to do it?
_______________________________________________________________
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/
November 9, 2010 at 1:11 pm
Sean Lange (11/9/2010)
I thought maybe they stood for no chance this person is qualified for the "DB_Developer" position and should therefore keep looking for the entry level position. 😛 You will not be successful in a new job that you are under qualified for. What are you going to do when asked to something as simple as this at work and you have no idea how to do it?
That's obvious!
Put "Senior DBA" on the resume and hope the next company hires you fast.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
November 10, 2010 at 10:15 am
Yowch! So that's what a feeding frenzy on a newbie looks like from the outside. Lesson learned for me. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
November 10, 2010 at 10:36 am
Jeff Moden (11/10/2010)
Yowch! So that's what a feeding frenzy on a newbie looks like from the outside. Lesson learned for me. 😉
so you can teach an old dog new tricks 😛
November 10, 2010 at 10:49 am
Geoff A (11/10/2010)
Jeff Moden (11/10/2010)
Yowch! So that's what a feeding frenzy on a newbie looks like from the outside. Lesson learned for me. 😉so you can teach an old dog new tricks 😛
Absolutely. And a very good new trick it was at that.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 14 posts - 16 through 28 (of 28 total)
You must be logged in to reply to this topic. Login to reply