It would have helped if you had described what that value represents in terms of this data but your reference to
sic:
this type of any function is there in SQL or ACCESS or MYSQL
leads me to think of
mathematical functions[
^]
Of the data shown
Average = 18
Median = 20
There is no mode
However the
range is 15 so this query will get the results you want:
select max(age) - min(age) as ageRange from Table1
[EDIT]
My somewhat sarcastic solution above didn't go down so well. However, despite what other members are saying
it is possible to filter the table without using
WHERE
. The real point is that you really shouldn't do it this way! (And I really do mean really).
It can be achieved using a
CURSOR[
^] and an
IF[
^] statement. For example:
declare @AgeToCheck int = 15
declare @ResultFound int = 0
declare @name varchar(125)
declare @age int
declare @address varchar(125)
declare @city varchar(125)
declare @state varchar(125)
DECLARE @ACursor CURSOR
SET @ACursor = CURSOR FOR
SELECT [name], age,[address], city,[state]
FROM Table1
OPEN @ACursor
FETCH NEXT FROM @ACursor INTO @name, @age, @address, @city, @state
WHILE @@FETCH_STATUS = 0
BEGIN
IF @age = @AgeToCheck
BEGIN
SET @ResultFound = 1
BREAK
END
FETCH NEXT FROM @ACursor INTO @name, @age, @address, @city, @state
END
CLOSE @ACursor
DEALLOCATE @ACursor
select @name,@age,@address,@city,@state
Now doesn't that look horrible compared to
SELECT [name], age,[address], city,[state]
FROM Table1
WHERE age = @AgeToCheck
I cannot stress strongly enough that, just because something is possible does not mean that it is a sensible solution. Do not filter tables using Cursors.