Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
amalipriya
Starting Member
3 Posts |
Posted - 2012-11-29 : 09:47:48
|
Dear AllBelow is my resultant table:I want to order the resultant rows dynamically.CustomerID DynamicOrder75 176 177 176 277 278 280 381 3 If I pass DynamicOrder =2I need the result as belowCustomerID DynamicOrder75 276 277 376 177 178 180 381 3 And also distinct of customerIDPlease do help me. |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-11-29 : 10:09:32
|
After having read through your post couple of times, I am unable to understand the logic you are using to get the results. What are the rules to be used to change the DynamicOrder associated with CustomerID=75, for example? |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2012-11-29 : 18:35:46
|
I also am unclear on your requirements but perhaps this is a small step in the right direction. If not, feel free to disregard entirely...[CODE]order by case when DynamicOrder = @DynamicOrder then 1 else 2 end, DynamicOrder, CustomerID[/CODE]=================================================Hear the sledges with the bells - silver bells! What a world of merriment their melody foretells! |
|
|
amalipriya
Starting Member
3 Posts |
Posted - 2012-12-01 : 01:41:58
|
Sorry For not making you to understand my requirements.Let me explain. This is all about customers. I have 4 searches as below:Customer who did not made sales - between dateCustomer never calledCalled Customer - between datesCustomer Added - Between datesSo I have 4 queries for above search.Because I have to search in different tables for above conditions.I have to combined all the results in one table and show.My requirement is, I need to order the search query itself. For example, I need the customers who never made order on top and it will be dynamic. Next time I need the called customer should appear on top. How to I do this?Hope it's clear now. |
|
|
Elizabeth B. Darcy
Starting Member
39 Posts |
Posted - 2012-12-01 : 08:26:46
|
Is there a column in your table that indicates the customer action? Or, perhpas is the value in the DynamicOrder column is indicative of the customer action? If that indeed is so, the example you posted does not seem to be consistent with that conjecture (because, as Sunita pointed out in her response, CustomerID = 75 has DynamicOrder = 1 in the first result set and DynamicOrder = 2 in the second result set).______________________________________________-- "If a book is well written, I always find it too short" |
|
|
|
|
|
|
|