Quote:> I was wondering if there is anyway to Keep you order when using the IN
> statement.. For Example.. I have an ID Field and i want to grab a a
certain
> number of fields.. But it is important that i keep the order in which the
ID
> fields are in the Array list.. something like this Select * From Customer
> where IN (1, 6, 2, 5, 10).. what is happening is the results are coming
> back to me in order of the ID field not the order i have in the IN list..
is
> there any way or some syntax that i am not aware of that will keep the
> results in the order i ask!! Thanks..
Just ORDER BY your results if possible.
--
Patrick Logan, MCSD
Senior Technical Development Advisor
McKessonHBOC -- Extended Care Solutions Group
(417) 874-4000 ext. 4424
If you will see the query plan for your SQL you will see that it isQuote:> I was wondering if there is anyway to Keep you order when using the IN
> statement.. For Example.. I have an ID Field and i want to grab a a
certain
> number of fields.. But it is important that i keep the order in which
the ID
> fields are in the Array list.. something like this Select * From
Customer
> where IN (1, 6, 2, 5, 10).. what is happening is the results are
coming
> back to me in order of the ID field not the order i have in the IN
list.. is
> there any way or some syntax that i am not aware of that will keep the
> results in the order i ask!! Thanks..
The result you sought requires a cursor .. or some more line of code, I
dont think you can get it in one select statement ..
sarosh
--
http://www.manyQuestions.com
FREE sample certification Exams, FAQs, Code Samples, interview
Questions, job search, resume writing etc.
Sent via Deja.com http://www.deja.com/
Before you buy.
If you will see the query plan for your SQL you will see that it isQuote:> I was wondering if there is anyway to Keep you order when using the IN
> statement.. For Example.. I have an ID Field and i want to grab a a
certain
> number of fields.. But it is important that i keep the order in which
the ID
> fields are in the Array list.. something like this Select * From
Customer
> where IN (1, 6, 2, 5, 10).. what is happening is the results are
coming
> back to me in order of the ID field not the order i have in the IN
list.. is
> there any way or some syntax that i am not aware of that will keep the
> results in the order i ask!! Thanks..
The result you sought requires a cursor .. or some more line of code, I
dont think you can get it in one select statement ..
sarosh
--
http://www.manyQuestions.com
FREE sample certification Exams, FAQs, Code Samples, interview
Questions, job search, resume writing etc.
Sent via Deja.com http://www.deja.com/
Before you buy.
> If you will see the query plan for your SQL you will see that it is
> converted into bunch id = 1 or id = 6 or id = 2 ..etc .. now this
> query plan is excuted and the results are returned .. to get the
result
> in any specific order you have to specify the order by column ..
> The result you sought requires a cursor .. or some more line of code,
I
> dont think you can get it in one select statement ..
> sarosh
> --
SELECT id, case id when 2 then 1
when 1 then 2
when 3 then 3
else 0
end AS ORDER_1
FROM tablename
WHERE id IN (2,1,3)
ORDER BY ORDER_1;
Rafat Sarosh
---------------------------------------
http://www.manyQuestions.com
FREE sample certification Exams, FAQs, Code Samples, interview
Questions, job search, resume writing etc.
Sent via Deja.com http://www.deja.com/
Before you buy.
1. IF- statements in a rule's 'DO INSTEAD SELECT ...'- statement
Hello, all,
Can I insert IF- statements into a rule's DO INSTEAD- clause ? I have the
problem in a situation like :
create rule vprinsert as on insert to vpr_status
do instead (DDDDD);
if I insert as DDDDD a genuine SELECT- statement (or, Alvaro, several select
statements), everything is OK; but if I start inserting IF- statements, it's
not OK any more (syntax errors). Don't I just know the exact syntax, or is
this simply impossible ?
Anyone any idea on how to resolve this ?
Regads,
Philippe Bertin.
P.S. To have an idea why I want to insert IF- statements into the rule,
please refer to my newsgroup posting of last Friday ...
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
2. How to use the contents of a Varchar as a literal
3. Case Statement in Update Statement
4. two instance of SQL Server on the same machine
5. Switch Statement / Case Statement ?
7. Running SELECT statement within EXECUTE statement
8. Log File Question.... Little different.
9. Sleeping SELECT statement is blocking another statement
10. Combine a Loop Statement and If Statement?
11. While statement inside If statement
12. if statement not allowed in derived table statement??
13. HOW TO create cursor from dynamic SQL statement (EXECUTE(@Statement))