Publicis Sapient Interview Question

Based on Normalised Tables. Write a query to find out latest inserted row.

Interview Answers

Anonymous

Sep 10, 2014

Basically Id will be max so select Max(Id). Was not this straight forward but basic logic was this.

Anonymous

Sep 12, 2014

Ideally the question is itself wrong if it was asked the same way. There is no ordering of rows/records in a table, thus you cannot identify first or last inserted record. SQL works in terms of sets, thus a table is an un-ordered set of records. If the table has an IDENTITY key on a column & simple insert had happened without overriding the IDENTITY property then it can be identified by taking MAX() of the IDENTITY column, similar to what someone previously answered.