Tag: SQL Joins

Nov 05

SQL Query – Customer having maximum number of accounts

Interview questions

Today, we will discuss one interested and most frequently asked interview question in sql server on customer and account table. I asked this question to may candidates, some gave right answer and some failed to answer it. The question was “Write down sql query to retrieve the customer having maximum number of accounts”. The problem …

Continue reading »

Oct 15

SQL Joins – Full Outer Join

Full Outer Join or Full Join join combines the results of both left(Table 1) and right(Table 2) outer joins and returns all (matched or unmatched) rows from the tables on both sides of the join clause. This means that full outer join combines the effect of applying both left and right outer joins.     Let’s take …

Continue reading »

Oct 15

SQL Joins – Right Join

Right Outer Join or Right Join returns all record from right table (table 2) and matched records from left table (table 1). If the record does not match it, returns NULL from left side (table 1) table.     Let’s take an example of Employee (Table 1) and Department (Table 2) table discussed in SQL …

Continue reading »

Oct 15

SQL Joins – Left Join

Left Outer Join or Left Join returns all record from left table (table 1) and matched records from right table (table 2). If the record does not match it, returns NULL from right side table.   Let’s take an example of Employee (Table 1) and Department (Table 2) table discussed in SQL Joins post where DepartmentId used …

Continue reading »

Oct 15

SQL Joins – Cross Join

Cross Join returns Cartesian product of rows from tables used. In other words, it will produce rows, which combines each row from first table with each row from second table. Let’s take an example of Department and Employee Tables. The Employee Tables contains nine rows and Department table contains five rows so the Cross Join will …

Continue reading »