Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Reg: Interview Questions Expand / Collapse
Author
Message
Posted Tuesday, November 06, 2012 4:59 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Today @ 12:09 AM
Points: 54, Visits: 309
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 .






Post #1381751
Posted Tuesday, November 06, 2012 5:01 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 1:13 AM
Points: 38,103, Visits: 30,394
So, what do you have so far?


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1381752
Posted Tuesday, November 06, 2012 6:13 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, January 15, 2013 11:11 AM
Points: 1,945, Visits: 2,782
>> I face one interview question. One salary table I have three columns like (id,name,salary) <<

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.

Oh, you forgot the DDL that is minimal Netiquette.

CREATE TABLE Salary_Details
(emp_id INTEGER NOT NULL PRIMARY KEY,
emp_name VARCHAR(25) NOT NULL,
salary_amt DECIMAL (8,2) NOT NULL
CHECK ( salary_amt >= 0.00) );

>> In this above I want following result <<

What is the business rule for the computation?


Books in Celko Series for Morgan-Kaufmann Publishing
Analytics and OLAP in SQL
Data and Databases: Concepts in Practice
Data, Measurements and Standards in SQL
SQL for Smarties
SQL Programming Style
SQL Puzzles and Answers
Thinking in Sets
Trees and Hierarchies in SQL
Post #1381762
Posted Wednesday, November 07, 2012 1:46 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 1:08 AM
Points: 2,369, Visits: 4,411
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



Kingston Dhasian

How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1381826
Posted Wednesday, November 07, 2012 1:50 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 1:08 AM
Points: 2,369, Visits: 4,411
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.



Kingston Dhasian

How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1381829
Posted Wednesday, November 07, 2012 1:52 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 9:40 AM
Points: 2,596, Visits: 4,507
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...


_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!"
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Post #1381832
Posted Wednesday, November 07, 2012 2:07 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Yesterday @ 10:57 AM
Points: 838, Visits: 2,200
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
Post #1381834
Posted Wednesday, November 07, 2012 2:25 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Yesterday @ 4:21 PM
Points: 512, Visits: 2,245
I think the question is to see if you know how to transpose rows to columns.

-----------------------------------
http://www.SQL4n00bs.com
Post #1381839
Posted Wednesday, November 07, 2012 2:33 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, May 17, 2013 6:07 AM
Points: 62, Visits: 227
Using inner join A.id=B.id-1

Using cte expression and join
Post #1381843
Posted Wednesday, November 07, 2012 2:38 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Yesterday @ 10:57 AM
Points: 838, Visits: 2,200
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
Post #1381849
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse