Query problem [modified]
-
i am using sql server database please check the below table two columns say column A and Column B
A B
1 100
1 200
1 300
2 100
2 200
3 100if the user give 100,200 and 300 i want return 1 ( which has all these values) if the user give 100 and 200 i have to give 1 and 2. Hope this is clear.... Please help me to build the query
My small attempt...
modified on Thursday, June 4, 2009 7:50 AM
-
i am using sql server database please check the below table two columns say column A and Column B
A B
1 100
1 200
1 300
2 100
2 200
3 100if the user give 100,200 and 300 i want return 1 ( which has all these values) if the user give 100 and 200 i have to give 1 and 2. Hope this is clear.... Please help me to build the query
My small attempt...
modified on Thursday, June 4, 2009 7:50 AM
Hello this time the question is not clear. Please be more specific. This is a very poor way of asking your question. Please define the function mapping your input to output more specifically Tell us the desired output. Is it For case 1: Input 100,200,300
Output:
A B
1 100
1 200
1 300For Case 2: I/P: 100 , 200
O/P:
A B
1 100
1 200
2 100
2 200OR
A B
1 100
2 200? Please from next time whenever you post, give the sample output so that it will be easy to solve. Also, are you passing a comma delimited value or what? Nothing clear!: :( :)
Niladri Biswas
modified on Sunday, June 7, 2009 2:39 AM
-
Hello this time the question is not clear. Please be more specific. This is a very poor way of asking your question. Please define the function mapping your input to output more specifically Tell us the desired output. Is it For case 1: Input 100,200,300
Output:
A B
1 100
1 200
1 300For Case 2: I/P: 100 , 200
O/P:
A B
1 100
1 200
2 100
2 200OR
A B
1 100
2 200? Please from next time whenever you post, give the sample output so that it will be easy to solve. Also, are you passing a comma delimited value or what? Nothing clear!: :( :)
Niladri Biswas
modified on Sunday, June 7, 2009 2:39 AM
Anyway Assuming that For case 1:
Input 100,200,300
Output:
A B
1 100
1 200
1 300Solution SELECT MIN(A), B FROM tbl_test WHERE B IN (100, 200, 300) GROUP BY B; For Case 2:
I/P: 100 , 200
O/P:
A B
1 100
1 200
2 100
2 200Solution is SELECT A, B FROM tbl_test WHERE B IN (100, 200) ORDER BY A, B; hope this helps. And vote me :) And from next time please define the function mapping your input to output more specifically :)
Niladri Biswas