Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a table that has
brand varchar[50]
seller varchar[50]
cost int
i want to show min and max cost sepretally in gridview
for example..
min=cost[min]
max=cost[max]
Posted
Comments
Mike Meinz 17-Nov-13 7:54am    
Math.Min and Math.Max are the methods that you use to compare the values in an array. If you mean DataTable or database table and not array, then your SQL statement would be similar to SELECT MIN(cost),Max(cost) from tablename.
m-e-h-d-h-i 17-Nov-13 9:08am    
thanks...
m-e-h-d-h-i 17-Nov-13 9:18am    
What can i do when i want to show this min,max and some column such as name,image from other db(Ex table named [cpu])
in same gridview ?

1 solution

SQL:
Total Min and Max
SQL
SELECT MIN(cost), MAX(cost)
FROM Tablename


Brand Min and Max
SQL
SELECT Brand, MIN(cost), MAX(cost)
FROM Tablename
GROUP BY Brand


Seller Min and Max
SQL
SELECT Seller, MIN(cost), MAX(cost)
FROM Tablename
GROUP BY Seller


For further information, please use SearchBox[^].
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900