Interview Question


Country: United States




Comment hidden because of low score. Click to expand.
2
of 2 vote

Are we allowed to modify the table? If yes, then the best strategy is to add an extra column column called "last_update_date". Now, you can easily query for extracting incremental records from the table.

- chandershivdasani August 22, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Using timestamp.

- Vincent August 22, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Why Add new column

UPDATE p1 SET p1.LastName='Test' FROM Persons P1
JOIN Persons p2 ON p1.P_Id = p2.P_Id
WHERE p1.p_id IN (SELECT TOP 2 p_id from Persons ORDER By p_id desc);

- Anonymous September 08, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

why do u join this table ? would nt this gives the same result ??

UPDATE p1 SET p1.LastName='Test' FROM Persons P1
where p1.p_id IN (SELECT TOP 2 p_id from Persons ORDER By p_id desc);

- dildileepkumar October 06, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

i mean add trigger for each insert

- sjh February 09, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

How about using triggers on each update?

- sjh February 09, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

If we are not allowed to modify the table, maybe we can create an extra table in the database to store the data from yesterday. When there are newly added data, we can use MINUS to get the difference of the two tables..

- Evan August 22, 2012 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More