minumn and maximum

  • Thread starter Thread starter AAA
  • Start date Start date
A

AAA

what is the mininum and maximum value in SQL statement

select * from table1 where field1 between "minumum" and "maximum"

then it will show up all the value in table1

thank

regards
 
To show up all the values in the table you don't need to use the Where clause.

In order for your SQL Statement to work as you wish you should put the
min/max aggregate function inside a subquery, therefor you SQL Statement
should look like this:

select * from table1 where field1 between
(Select Min(feild1) From table1) And
(Select Max(feild1) From table1)

but again, I must say that it will be better to remove the where clause to
see all the records in the table.
 
I'm not sure what you want :

1) To show all : SELECT * FROM Table1

2) To find out min, max values : SELECT MIN(Field) AS MinField,MAX(Field) AS
MaxField FROM Table1

Patrice
 
select * from table1 where field1 >= 5 and field1 <= 11

I think this is what you are looking for.
 
AAA said:
what is the mininum and maximum value in SQL statement

select * from table1 where field1 between "minumum" and "maximum"

then it will show up all the value in table1

thank

regards

select * from table1 where field1 between 1 and 10.

Minimum is the lowest point of the range to find.
Maximim is the highest point of the range to find.

So, only those rows where field1 is greater than or equal to 1 and less than
or equal to 10 will be returned.

Mythran
 
Actually, I create a few textboxs for user to enter criteria for them to
search the data under vb.net application.

when user leave the texbox(criteria) is blank, it will show up all the data.

my SQL statement would be like

select * from table1 where field1 between textbox1.text and textbox2.text
AND field2 between textbox3.text and textbox4.text........until field 5.

When user key in something in the textbox, then I just simply use the
textbox value. then no problem for my sql statment.

but when user leave all textbox(criteria) blank, meaning that the user want
to see all information, then I can not bring the textbox blank value in the
sql statement, because there is no such function like "select * from table1
where field between and "......because my textbox are blank value.....

so I am thinking to find out the min value of ascii code and max value of
ascii, so when it detect my textbox1.text is blank, then it will not be
shown blank, but instead of the mininum value of ascii code.

"select * from table1 where field between (min value ascii) and (max value
of ascii)"
 
Back
Top