kapcan.88
kapcan.88

Reputation: 3

to view list from MIN to AVG

This code sorted list and output is 1, but i need to view the list

SELECT AVG(CustomerID) 
FROM Customers
WHERE CustomerID =  ( SELECT  MIN(CustomerID) FROM Customers  )

Upvotes: 0

Views: 37

Answers (2)

D-Shih
D-Shih

Reputation: 46239

From your question you need to get AVG and MIN Value then Compare.

SELECT CustomerID 
FROM Customers T 
INNER JOIN
(
    SELECT MIN(CustomerID) m, AVG(CustomerID) a
    FROM Customers
) T2 ON T.CustomerID >=m AND T.CustomerID <= a

sqlfiddle

Upvotes: 1

Kedar Limaye
Kedar Limaye

Reputation: 1041

I dont understand why you are averaging customerid But still

select * from customers where customerid <
(SELECT avg(customerid) FROM Customers))

Upvotes: 0

Related Questions