November 6, 2012 at 4:59 pm
I face one interview question.One salary table i have three column like (id,name,salary)
Table Name:SalaryDetail
id name salary
1 arun 1000
2 jothi 2000
3 kavi 3000
4 rahul 4000
5 jeeva 5000
In this above i want following result
id name salary Salry2
1 arun 1000 null
2 jothi 2000 1000
3 kavi 3000 2000
4 rahul 4000 3000
5 jeeva 5000 4000.
Please reply this .
November 6, 2012 at 5:01 pm
So, what do you have so far?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
November 7, 2012 at 1:46 am
vs.satheesh (11/6/2012)
I face one interview question.One salary table i have three column like (id,name,salary)Table Name:SalaryDetail
id name salary
1 arun 1000
2 jothi 2000
3 kavi 3000
4 rahul 4000
5 jeeva 5000
In this above i want following result
id name salary Salry2
1 arun 1000 null
2 jothi 2000 1000
3 kavi 3000 2000
4 rahul 4000 3000
5 jeeva 5000 4000.
Please reply this .
What is the business logic by which you got the 4th column( Salry2 )?
Though it is a bit evident, it would be better if you put it in words as otherwise people would only be guessing
Additionally, if you include some code which you have come up with, we can be assured we are not spoon feeding you
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
November 7, 2012 at 1:50 am
CELKO (11/6/2012)
Now we have to track down this interview so we can tell them that you cheat. I have gotten two students and one lecturer kicked out of their schools for this kind of academic dishonesty.
How does the thread classify as "Academic dishonesty"?
The OP is most probably a job seeker and not a student. He is asking this question after the interview to gain some knowledge which he doesn't have now.
He would have been dishonest had he asked the question during the interview process which is highly unlikely.
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
November 7, 2012 at 1:52 am
CELKO (11/6/2012)
...Now we have to track down this interview so we can tell them that you cheat
...dishonesty...
So, can you claim that you have never-ever lied yourself?
😉
I guess OP had the interview already, and couldn't answer the question he is asking to help with...
November 7, 2012 at 2:07 am
I think they were probably testing your knowledge of Joins, it would be interesting to see what you think the solution is before putting up how I would have coded.
_________________________________________________________________________
SSC Guide to Posting and Best Practices
November 7, 2012 at 2:25 am
I think the question is to see if you know how to transpose rows to columns.
---------------------------------------------------------
It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
David Edwards - Media lens[/url]
Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
Howard Zinn
November 7, 2012 at 2:33 am
Using inner join A.id=B.id-1
Using cte expression and join
November 7, 2012 at 2:38 am
The inner join wont work where Id 1 which needs to return a NULL value, based on the sample data provided, so you would need a Left outer join, to the prior record based on Id.
_________________________________________________________________________
SSC Guide to Posting and Best Practices
November 7, 2012 at 3:26 am
SELECT ID=ID,
NAME=NAME,
SALARY=SALARY,
SALARY2=(case when SALARY-1000=0 then null else SALARY-1000 end)
FROM SalaryDetail
November 7, 2012 at 6:34 am
Kingston Dhasian (11/7/2012)
CELKO (11/6/2012)
Now we have to track down this interview so we can tell them that you cheat. I have gotten two students and one lecturer kicked out of their schools for this kind of academic dishonesty.How does the thread classify as "Academic dishonesty"?
The OP is most probably a job seeker and not a student. He is asking this question after the interview to gain some knowledge which he doesn't have now.
He would have been dishonest had he asked the question during the interview process which is highly unlikely.
Not at all unlikely. See it happen all the time.
That's why I always wait at least an hour from when these kinds of questions are posted before I post any sort of answer to the problem. Assuming some of the questions are homework, as opposed to interviews/tests, I sometimes wait a full day.
That way, if it's an honest "I came up short and I'd like some help so I can do better next time", they get what they need, but if it's a dishonest, "I'm in the middle of a test/interview and I'm trying to lie my way to (a better grade)/(a job I don't actually qualify for)", I'm not helping with that.
Either way, this one is too vague to actually provide real answers to. Are they trying to grab the value from the prior row? Are they looking for val-1000? Something else? It's too vague. In an interview, asked this exact question, I'd tell them my response would be, "The request is too vague. I need to know the actual business rules being applied here. Please contact the stakeholder and get the request clarified."
- 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
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply