Microsoft Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




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

SELECT c.cust_id,
COUNT(o.order_id) ct
FROM customer c,
order1 o
WHERE c.cust_id = o.cust_id
GROUP BY c.cust_id
HAVING COUNT(o.order_id) >= 1
ORDER BY ct DESC

- Anonymous March 15, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select C.cust_id, C.cust_name, Count(*) as Total_Order
From Order O
Join Customer C
On O.cust_id = C.cust_id
Group By O.cust_id

- Rushmee July 19, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

here having clause should also be used..as we have to print the customer name having atleast one order.

select c.cust id, c.cust name,count(*) from customer c, order o where c.cust id= o.cust id group by c.cust id having count(*)>=1;

- Deepika September 23, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select customers.customername, customers.customerid,count(orders.orderid)
from customers join orders on customers.customerid= orders.customerid group by customers.customername

- swapnil October 16, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

{select customers.customername, customers.customerid,count(orders.orderid)
from customers join orders on customers.customerid= orders.customerid group by customers.customername}

- swapnil October 16, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

CREATE TABLE Customers(Cust_Id INT, Cust_Name VARCHAR(50), Age INT)
CREATE TABLE Orders(Order_Id INT, Cust_Id INT, Order_Date DATETIME)

INSERT INTO Customers VALUES (1,'ABC',30), (2,'ABC2',35), (3,'ABC3',33), (4,'ABC4',34), (10,'ABC10',30)

INSERT INTO Orders VALUES(100,1, GETDATE()), (101,2, GETDATE()), (103,3, GETDATE()), (110,1, GETDATE()), (120,1, GETDATE()), (104,4, GETDATE())

SELECT DISTINCT c.Cust_Id, c.Cust_Name, COUNT(1) AS [TotalOrders] FROM Customers c
INNER JOIN Orders o ON c.Cust_Id = o.Cust_Id
GROUP BY c.Cust_Id, c.Cust_Name

- rp.arunachalam May 15, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select cust.cust_id,cust.cust_name, x.count from customer cust,(select o.cust_id, count(*)as count from order o group by order o) x where cust.cust_id = x.cust_id

- Ujjwal June 26, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select cust.cust_id, cust.cust_name,x.total_order from customer cust,(select o.cust_id, count(*) as total_order from order o group by o.cust_id) x where cust.cust_id= x.cust_id

- Ujjwal June 26, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select cust.cust_id, cust.cust_name,x.total_order from customer cust,(select o.cust_id, count(*) as total_order from order o group by o.cust_id) x where cust.cust_id= x.cust_id

- Ujjwal June 26, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select cust.cust_id, cust.cust_name,x.total_order from customer cust,(select o.cust_id, count(*) as total_order from order o group by o.cust_id) x where cust.cust_id= x.cust_id

- Ujjwal June 26, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

SELECT o.customerid,c.customername, count(o.orderid) as total_orders FROM Orders o LEFT JOIN customers c on o.customerid=c.customerid group by o.customerid, c.customername;

- Shrenik December 01, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

SELECT o.customerid,c.customername, count(o.orderid) as total_orders FROM Orders o LEFT JOIN customers c on o.customerid=c.customerid group by o.customerid, c.customername;

- Shrenik December 01, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

SELECT o.customerid,c.customername, count(o.orderid) as total_orders FROM Orders o LEFT JOIN customers c on o.customerid=c.customerid group by o.customerid, c.customername having count(o.orderid)>=1;

- kunfupanda December 01, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select a.cust_id,a.cust_name, count(b.order_id) as total
From Customer as a left join [Order] as b
on a.cust_id=b.cust_id
group by a.cust_id,a.cust_name
having count(b.order_id)>=1
order by a.cust_id

- rank.rao.7.n February 05, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select count(*) as orders, c.cust_id,cust_name
from customers c, orders o
where c.cust_id=o.cust_id
group by c.cust_id,cust_name
having count(*)>1

- Nikhil August 01, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Select o.cust_id, c.cust_name, count(o.order_id)
from cust c join orders o
on c.cust_id = o.cust_id
group by o.cust_id, c.cust_name
having count(o.order_id) > 1

- umatrika November 16, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Is it total number of orders or total amount of orders. Table structure is not complete either..

select o.cust_id,c.cust_name,sum(o.amount) as total_amt from orders o
left outer join customers c on
o.cust_id=c.cust_id
group by o.cust_id,c.cust_name
having count(o.order_id) >0

OR

select o.cust_id,c.cust_name,count(o.order_id) as total_orders from orders o
left outer join customers c on
o.cust_id=c.cust_id
group by o.cust_id,c.cust_name
having count(o.order_id) >0

- itsmeashishsingh February 06, 2019 | 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