Author |
Topic |
krish001
Yak Posting Veteran
61 Posts |
Posted - 2009-10-06 : 13:57:04
|
hi,plz i need very urgentIam having 5 columns where i want the lowest value among them problem is when there are NULL values i used isnull to make them as '0' so always iam getting the '0' as lowest values...col1 col2 col3 col4 col51 2 3 null null expected is lowest =1 but iam getting '0'..... plz solve this....thank you |
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-10-06 : 14:48:02
|
in the isnull statement replace them with the highest value instead of '0'..something like '9999' or something. |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-07 : 02:20:09
|
quote: Originally posted by krish001 hi,plz i need very urgentIam having 5 columns where i want the lowest value among them problem is when there are NULL values i used isnull to make them as '0' so always iam getting the '0' as lowest values...col1 col2 col3 col4 col51 2 3 null null expected is lowest =1 but iam getting '0'..... plz solve this....thank you
Post the code you usedMadhivananFailing to plan is Planning to fail |
 |
|
krish001
Yak Posting Veteran
61 Posts |
Posted - 2009-10-07 : 03:00:17
|
quote: Originally posted by vijayisonly in the isnull statement replace them with the highest value instead of '0'..something like '9999' or something.
Thank you it is working... |
 |
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-10-07 : 03:02:56
|
select min(column) from table where column is not nullSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-07 : 06:01:43
|
quote: Originally posted by krish001
quote: Originally posted by vijayisonly in the isnull statement replace them with the highest value instead of '0'..something like '9999' or something.
Thank you it is working...
Did you see my first reply?MadhivananFailing to plan is Planning to fail |
 |
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2009-10-07 : 07:12:37
|
quote: Originally posted by madhivanan
quote: Originally posted by krish001
quote: Originally posted by vijayisonly in the isnull statement replace them with the highest value instead of '0'..something like '9999' or something.
Thank you it is working...
Did you see my first reply?MadhivananFailing to plan is Planning to fail
Yes. Yes, I DID see your first post, however, I got the answer hand fed to me, and have no need of you or your questions. Have a nice day!</sarcasm>http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-07 : 09:49:25
|
quote: Originally posted by DonAtWork
quote: Originally posted by madhivanan
quote: Originally posted by krish001
quote: Originally posted by vijayisonly in the isnull statement replace them with the highest value instead of '0'..something like '9999' or something.
Thank you it is working...
Did you see my first reply?MadhivananFailing to plan is Planning to fail
Yes. Yes, I DID see your first post, however, I got the answer hand fed to me, and have no need of you or your questions. Have a nice day!</sarcasm>http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp
I wanted to show OP the way without worrying about NULLsMadhivananFailing to plan is Planning to fail |
 |
|
X002548
Not Just a Number
15586 Posts |
|
krish001
Yak Posting Veteran
61 Posts |
Posted - 2009-10-08 : 03:47:22
|
quote: Originally posted by madhivanan
quote: Originally posted by krish001 hi,plz i need very urgentIam having 5 columns where i want the lowest value among them problem is when there are NULL values i used isnull to make them as '0' so always iam getting the '0' as lowest values...col1 col2 col3 col4 col51 2 3 null null expected is lowest =1 but iam getting '0'..... plz solve this....thank you
Post the code you usedMadhivananFailing to plan is Planning to fail
i used this code casewhen Min(isnull([Cff Rating 1],9999)) <=Min(isnull([Cff Rating 2],9999)) and Min(isnull([Cff Rating 1],9999)) <=Min(isnull([Cff Rating 3],9999)) AND Min(isnull([Cff Rating 1],9999)) <=Min(isnull([Cff Rating 4],9999)) AND Min(isnull([Cff Rating 1],9999)) <=Min(isnull([Cff Rating 5],9999))then Min(isnull([Cff Rating 1],9999))when Min(isnull([Cff Rating 2],9999)) <= Min(isnull([Cff Rating 1],9999)) and Min(isnull([Cff Rating 2],9999)) <= Min(isnull([Cff Rating 3],9999)) AND Min(isnull([Cff Rating 2],9999)) <= Min(isnull([Cff Rating 4],9999)) AND Min(isnull([Cff Rating 2],9999)) <= Min(isnull([Cff Rating 3],9999)) then Min(isnull([Cff Rating 2],9999)) when Min(isnull([Cff Rating 3],9999)) < =Min(isnull([Cff Rating 1],9999)) and Min(isnull([Cff Rating 3],9999)) <= Min(isnull([Cff Rating 2],9999))AND Min(isnull([Cff Rating 3],9999)) < =Min(isnull([Cff Rating 4],9999)) AND Min(isnull([Cff Rating 3],9999)) < =Min(isnull([Cff Rating 5],9999)) then Min(isnull([Cff Rating 3],9999)) when Min(isnull([Cff Rating 4],9999)) < =Min(isnull([Cff Rating 1],9999)) and Min(isnull([Cff Rating 4],9999)) <= Min(isnull([Cff Rating 2],9999))AND Min(isnull([Cff Rating 4],9999)) < =Min(isnull([Cff Rating 3],9999)) AND Min(isnull([Cff Rating 4],9999)) < =Min(isnull([Cff Rating 5],9999)) then Min(isnull([Cff Rating 4],9999))when Min(isnull([Cff Rating 5],9999)) < =Min(isnull([Cff Rating 1],9999)) and Min(isnull([Cff Rating 5],9999)) <= Min(isnull([Cff Rating 2],9999))AND Min(isnull([Cff Rating 5],9999)) < =Min(isnull([Cff Rating 3],9999)) AND Min(isnull([Cff Rating 5],9999)) < =Min(isnull([Cff Rating 4],9999)) then Min(isnull([Cff Rating 5],9999)) else 0 end as lowest |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-08 : 03:59:18
|
It may be something like thisselect unique_col,min(col1) as min_val from(select unique_col,col1 from your_tableunion allselect unique_col,col2 from your_tableunion allselect unique_col,col3 from your_tableunion allselect unique_col,col4 from your_tableunion allselect unique_col,col5 from your_table) as tgroup by unique_colMadhivananFailing to plan is Planning to fail |
 |
|
krish001
Yak Posting Veteran
61 Posts |
Posted - 2009-10-08 : 04:06:35
|
quote: Originally posted by madhivanan It may be something like thisselect unique_col,min(col1) as min_val from(select unique_col,col1 from your_tableunion allselect unique_col,col2 from your_tableunion allselect unique_col,col3 from your_tableunion allselect unique_col,col4 from your_tableunion allselect unique_col,col5 from your_table) as tgroup by unique_colMadhivananFailing to plan is Planning to fail
wat will be the unique_col |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-08 : 04:16:42
|
quote: Originally posted by krish001
quote: Originally posted by madhivanan It may be something like thisselect unique_col,min(col1) as min_val from(select unique_col,col1 from your_tableunion allselect unique_col,col2 from your_tableunion allselect unique_col,col3 from your_tableunion allselect unique_col,col4 from your_tableunion allselect unique_col,col5 from your_table) as tgroup by unique_colMadhivananFailing to plan is Planning to fail
wat will be the unique_col
The column which is unique in the tableMadhivananFailing to plan is Planning to fail |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-09 : 01:48:58
|
quote: Originally posted by krish001 hi,plz i need very urgentIam having 5 columns where i want the lowest value among them problem is when there are NULL values i used isnull to make them as '0' so always iam getting the '0' as lowest values...col1 col2 col3 col4 col51 2 3 null null expected is lowest =1 but iam getting '0'..... plz solve this....thank you
What did you change in this post?MadhivananFailing to plan is Planning to fail |
 |
|
|