Goldman Sachs Interview Question for Software Engineer / Developers






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

Joining Three or More Tables:
:

Although each join specification joins only two tables, FROM clauses can contain multiple join specifications. This allows many tables to be joined for a single query.

The titleauthor table of the pubs database offers a good example of a situation in which joining more than two tables is helpful. This Transact-SQL query finds the titles of all books of a particular type and the names of their authors:

USE pubs
SELECT a.au_lname, a.au_fname, t.title
FROM authors a INNER JOIN titleauthor ta
ON a.au_id = ta.au_id JOIN titles t
ON ta.title_id = t.title_id
WHERE t.type = 'trad_cook'
ORDER BY t.title ASC

.
.
.
Here is the result set:

au_lname | au_fname | title
----------------- -------------------- ----------
Blotchet-Halls | Reginald | Fifty Years in Buckingham Palace
Kitchens
Panteley | Sylvia | Onions, Leeks, and Garlic:
Cooking Secrets of the Mediterranean
O'Leary | Michael | Sushi, Anyone?
Gringlesby | Burt | Sushi, Anyone?
Yokomoto | Akiko | Sushi, Anyone?

(5 row(s) affected)
.
.
Notice that one of the tables in the FROM clause, titleauthor, does not contribute any columns to the results. Also, none of the joined columns, au_id and title_id, appear in the results. Nonetheless, this join is possible only by using titleauthor as an intermediate table.
.

The middle table of the join (the titleauthor table) can be called the translation table or intermediate table, because titleauthor is an intermediate point of connection between the other tables involved in the join.

When there is more than one join operator in the same statement, either to join more than two tables or to join more than two pairs of columns, the join expressions can be connected with AND or with OR.

- priyankajaggi4 January 12, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Can I know what are the queries?

- sureendarraju November 08, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

SELECT * FROM table1 NATURAL JOIN table2 NATURAL JOIN table3 WHERE Condition;

- Harish Arora May 03, 2013 | 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