Skip to content

Instantly share code, notes, and snippets.

@abrarShariar
Last active February 3, 2016 07:06
Show Gist options
  • Save abrarShariar/c425615f2a5ca862dfbf to your computer and use it in GitHub Desktop.
Save abrarShariar/c425615f2a5ca862dfbf to your computer and use it in GitHub Desktop.
SQL commands (sub query)
>>select customer_street from customer where customer_name in (select customer_name from borrower where loan_number in (select loan_number from loan where amount=(select max(amount) from loan)));
>> select amount from loan where amount>(select amount from loan where loan_number='L-15');
>> select customer_name,customer_city from customer where customer_name in (select customer_name from borrower where loan_number in (select loan_number from loan where branch_name in (select branch_name from loan where branch_name='Downtown')));
>> select customer_name,customer_city from customer where customer_name in (select customer_name from borrower);
>> select customer_name from borrower where loan_number in (select loan_number from loan where branch_name = (select branch_name from loan where loan_number=(select loan_number from borrower where customer_name='Adams')));
>> select customer_name from borrower where loan_number in (select loan_number from loan where branch_name='Perryridge');
>> select customer_name,loan_number from borrower where loan_number in (select loan_number from loan where amount=(select max(amount) from loan));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment