sql query
-
hi, i have three fields in the database table p1 p2 rank 10% 20% 3 21% 40% 2 now i am passing the input as 15%...this 15% is related to 3rd rank.. so i need the o/p rank as 3.. if the p1 and p2 datatypes are varchar..then how we can we write the query for that one tgo get the rank as 3. Ramesh
-
hi, i have three fields in the database table p1 p2 rank 10% 20% 3 21% 40% 2 now i am passing the input as 15%...this 15% is related to 3rd rank.. so i need the o/p rank as 3.. if the p1 and p2 datatypes are varchar..then how we can we write the query for that one tgo get the rank as 3. Ramesh
You haven't explained why a rank of 3 should be returned for 15% However I assume this is because 15% is between 10 and 20%. In this case, you shoul use the BETWEEN clause in your query. Why are you storing percentages in varchar fields? They are numbers, so they should be stored in numeric fields. You will run into problems every time you want to do numeric comparisons because you will need to case your varchar values to numbers.
Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush
-
hi, i have three fields in the database table p1 p2 rank 10% 20% 3 21% 40% 2 now i am passing the input as 15%...this 15% is related to 3rd rank.. so i need the o/p rank as 3.. if the p1 and p2 datatypes are varchar..then how we can we write the query for that one tgo get the rank as 3. Ramesh
select rank from table where input between P1 and P2
--Here 2 See Sharp-- I have not failed. I've just found 10,000 ways that won't work. :)