Computer Science, asked by akhilavijayan6379, 1 year ago

Write a query to find the highest average sales among all the salespersons using the given table.
Sample input
Table: Sales
Field Type
InvoiceNo Integer
SalesPerson Text
TotalSale Integer
Sample
InvoiceNo SalesPerson TotalSale
1 Acheson 50
2 Bryant 25
3 Bennett 250
4 Acheson 50
5 Bryant 100
6 Bennett 250
Sample output
max(totalsale)
250.0000

Answers

Answered by omegads03
12

The syntax for finding the average of any values in a table is as follows:

SELECT AVG(column_name)

FROM table_name;

Now for the given table ‘Sales’,

InvoiceNo SalesPerson TotalSale

     1                    Acheson       50

     2               Bryant       25

     3               Bennett     250

     4             Acheson       50

     5               Bryant      100

     6             Bennett      250

The following will find the average of the total sales.

SELECT AVG(TotalSale)

FROM Sales;

Output: 120.833  

Answered by mailforlalit
22

Answer:

select to_char(max(totalsale) ,'FM9999999999D000099')  from (select avg(totalsale) as totalsale from sales group by salesperson)

Explanation:

We can get average total saleand the max of it and than format it to match the  expected output.

Similar questions