I have a column containing the strings 'Operator (1)' and so on until 'Operator (600)' so far.
I want to get them numerically ordered and I've come up with
select colname from table order by
cast(replace(replace(colname,'Operator (',''),')','') as int)
which is very very ugly.
Better suggestions?
...
Is it possible to do a SELECT statement with a predetermined order, ie. selecting IDs 7,2,5,9 and 8 and returning them in that order, based on nothing more than the ID field?
Statements SELECT id FROM table WHERE id in (7,2,5,9,8); and SELECT id FROM table WHERE id in (8,2,5,9,7); both return them in the same order.
...
I have a bunch of records in several tables in a database that have a "process number" field, that's basically a number, but I have to store it as a string both because of some legacy data that has stuff like "89a" as a number and some numbering system that requires that process numbers be represented as number/year.
The problem arises ...
Is there a way of ordering a list of objects by a count of a property which is a collection?
For arguments sake let's say I have a question object with a question name property, a property that is a collection of answer objects and another property that is a collection of user objects. The users join the question table via foreign key ...
Hi,
I was wondering if anyone has a good solution to a problem I've encountered numerous times during the last years.
I have a shopping cart and my customer explicitly requests that it's order is significant. So I need to persist the order to the DB.
The obvious way would be to simply insert some OrderField where I would assign the n...
I have an interesting problem:
I'm building a web based image gallery program that right off the bat is going to include almost 7,000 images.
So, here's my question: What would be an optimal way to build an ordering system?
For example, if the admin wants to have the 4,984 image land in the 3,223 position (I work with some anal peopl...
I have two arrays containing the same elements, but in different orders, and I want to know the extent to which their orders differ.
The method I tried, didn't work. it was as follows:
For each list I built a matrix which recorded for each pair of elements whether they were above or below each other in the list. I then calculated a pea...
I am wondering if there is away (possibly a better way) to order by the order of the values in an IN() clause.
The problem is that I have 2 queries, one that gets all of the IDs and the second that retrieves all the information. The first creates the order of the IDs which I want the second to order by. The IDs are put in an IN() clause...
Let's say I have my pizza application with Topping and Pizza classes and they show in Django Admin like this:
PizzaApp
-
Toppings >>>>>>>>>> Add / Change
Pizzas >>>>>>>>>> Add / Change
But I want them like this:
PizzaApp
-
Pizzas >>>>>>>>>> Add / Change
Toppings >>>>>>>>>> Add / Change
...
I remember reading once that the order of the members of an evaluation is important.
Such as
if (null == myClass)
is better (faster?) then
if (myClass == null)
is this the case?
If so could someone explain how and why?
If the answer requires a language then aim towards c#.
Thanks
...
i have a List being returned from a daoTemplate.query() call, using a rowMapper.
the sql does an order by on a column, happens to be a date column, order by asc
when i use the List, am i always guaranteed that the list will be in the order dictated by the sql. can i depend that the first element (theList.get(0)), will ALWAYS be the earli...
Good afternoon,
I'm having trouble using the flowlayoutPanel in a C# winform application. What I basically have is a flow layout panel that has 3 sections.
Section #1 is a set of 2 controls .. two dropdown controls, they are always in the same order, always visible in all instances
Section #2 is a set of 5 different controls ... based...
So I have this query that is relatively fast at ~0.5 seconds but when I add an ORDER BY clause it jumps up to nearly 30 seconds.
Original query: (returns in ~0.5 seconds)
SELECT table1.*,table2.* FROM table1 LEFT OUTER JOIN table2 ON table1.column2=table2.column3 WHERE table1.column1='value' LIMIT 4
Query with ORDER BY: (returns in ~...
Hi!
Let's say I have the following model:
class Contest:
title = models.CharField( max_length = 200 )
description = models.TextField()
class Image:
title = models.CharField( max_length = 200 )
description = models.TextField()
contest = models.ForeignKey( Contest )
user = models.ForeignKey( User )
def score...
Hi,
I got an Java application using SQL tables that contains an ordered list of entities, ordered by
an order column. I would like to add/remove things in/from the middle
of the list. Now, I'm wondering if some persistence framework / orm / you-name-it
could provide this kind of functionality with batch update of order
column.
At the...
Suppose I have some objects, and I want the user to be able to reorder them in any way they wish, say, by dragging them around. So I'd have
cheese
muffins
milk
and then the user drags 'milk' to the top, making the new order
milk
cheese
muffins
Is there a best practice how to store the order of these objects in a database? The nai...
Assume I have a user defined Java class called Foo such as:
public class Foo
{
private String aField;
@Override
public String toString()
{
return aField;
}
}
and a Collection such as:
List<Foo> aList;
What I am looking to do is to sort the List alphabetically based upon each member's returned '.toString(...
Can anyone help me with this CAML query? When I flip the Ascending attribute from TRUE to FALSE (have also tried True and False), it doesn't re-order the result set.
The rest of the CAML is correct, it is being generated by a tool and the appropriate results are being returned.
<Where>
<And>
<And>
<Eq>
<FieldRef ...
In Oracle sql there is a feature to order as follow:
order by decode("carrot" = 2
,"banana" = 1
,"apple" = 3)
What will be the best way to implement this in python?
I want to be able to order a dict on its keys. And that order isn't alphabetically or anything, I determine the order.
...
I am using this SQL query to order a list of records by date in a php page.
SELECT ARTICLE_NO, USERNAME, ACCESSSTARTS, ARTICLE_NAME FROM table WHERE upper(ARTICLE_NAME) LIKE % x % ORDER BY str_to_date(ACCESSSTARTS, '%d/%m/%Y %k:%i:%s');
This works fine.
In a different php page, I want to be able to delete this record, and show the n...