Morgan Stanley Interview Questions
Practice with real Morgan Stanley interview questions
01
A Software Engineer was asked
Asked in 2024
Q. Can you explain the GROUP BY clause in SQL with an example using aggregate functions?
Ans. The GROUP BY clause in SQL is used to arrange identical data into groups with the help of aggregate functions. It is commonly used with functions like COUNT, SUM, AVG, MAX, and MIN to produce summary reports.
Example:
Suppose we have a
Sales table with the following columns: ProductID, Quantity, and Price.
To calculate the total quantity sold for each product, you can use the following query:
Output:
| ProductID | TotalQuantity |
|-----------|---------------|
| 1 | 13 |
| 2 | 5 |
| 3 | 7 |
In this example, we group the results by ProductID and use the SUM function to calculate the total quantity sold for each product. The query effectively summarizes the data, making it easier to analyze sales performance across different products.Software EngineerCore Concept
02
A Software Engineer was asked
Asked in 2024
Q. Can you describe the data structures Stacks and Queues? Provide examples in JavaScript.
Ans. Stacks and queues are fundamental data structures in computer science.
A stack follows the Last In First Out (LIFO) principle, where the last element added is the first one removed. Here’s a simple implementation in JavaScript:
A queue follows the First In First Out (FIFO) principle, where the first element added is the first one removed. Here’s a queue implementation:
Both stacks and queues are used in various applications, such as function call management (stacks) and task scheduling (queues). Always test for edge cases like underflows on pop or dequeue operations.
Software EngineerCore Concept
