Google Interview Question for Software Engineer / Developers


Country: India
Interview Type: In-Person




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

I am not sure if I have understood the question correctly but If we want to delete initial two rows from table we can use

delete from table_name limit 2;

it will delete initial two rows.

- Anonymous May 07, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
2
of 2 vote

DELETE FROM table
WHERE id in (SELECT TOP 2 * FROM table)

- shubhi May 18, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

I just didn't find out any way to represent the database table in proper format, so i just used the <tr> tags!
I am representing here the table in horizontal format :
NAME : zac zac zac zac zac
LOCATION : california california california california california

- ajaybhardwaj789 May 10, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Has any of the above answered your question?

- Fighter May 11, 2014 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

Hello everyone,

I hope I got the solution for deleting the first two rows from Oracle table. Run below query in oracle

delete from emp where rowid in(select rd from(select aa.*, rowid rd from emp aa where rownum <3 order by rowid) abc) ;

Regards,

Note: Please correct/update me if found anything new

- HeIsAlive July 29, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Not a DB guy, but giving it a try.

DELETE FROM <TABLE_NAME> WHERE <PK_COLUMN_NAME> IN (SELECT <PK_COLUMN_NAME> FROM <TABLE_NAME> WHERE ROWNUM<3)

- AlgoAlgae May 07, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Pretty Simple ---

delete from TABLE1 where rownum <=2

- Abhijeet Pawar May 07, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Is this table saved as a BLOB?

- Anonymous May 07, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Psudocode(I will prefer to write it in C#, Python or Java because of the iterator constructs available, but choose language of your choice) :
Continue while (Counter_to_be_deleted)
1. We instantiate an iterator for the xml/json.
2. When you hit tr tag(tr tag encloses one record), delete the element, update counter_to_be_deleted = counter_to_be_deleted - 1

- Rahul May 08, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

cant you just delete
2 of these rows?

<tr></tr>
<tr></tr>

done
tr means ROWS
hence the Table ROW initials TR

- geo May 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

continuing you should do that for the database but we do not know what database you are using
mongodb?
mysql?

nosql/sql?

parse?

etc the syntax would be different depending on each one then.
do you want it in javascript or do you want it in php or
other backend languages what?

not enough information on what type of database is being used.

- geo May 09, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

MySql Database!

- ajaybhardwaj789 May 10, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

in sybase, you can use set rowcount

- Anonymous July 27, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

DELETE FROM TABLE WHERE ROWNUM<=2;

- Pooja August 03, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

SELECT * FROM TABLE MINUS SELECT TOP 2 * FROM TABLE

- Pooja Karadgi August 03, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

DELETE FROM dbo.emp A
where A.empid in
(SELECT TOP 2 B.empid FROM dbo.emp B
MINUS
SELECT C.empid FROM dbo.emp C
)

- Anonymous February 26, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

delete top(2) from <tablename>

- Anonymous June 11, 2014 | 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