order

top 3 records ordered by a field in rails

In ruby on rails how do I find the top 3 records of my table called notices ordered by a particular field, in my case I want to order by the position field which is an integer. so my notices table looks like this any help would be greatly appreciated, thanks ...

Mapping a list in hibernate by ordering instead of an index-field

This works: <hibernate-mapping> <class name="Train" table="Trains"> <id column="id" name="id" type="java.lang.String" length="4"> <generator class="assigned" /> </id> <set name="trips" cascade="all"> <key column="trainId"/> <one-to-many class="Trip"/> </set> <...

How do i show the value of order comments in the order display grid?

I need to make use of the order comment history in sales order view page,and display the entered value in the order list.Though the textarea is for entering comment about order,I am using it to enter an id type value and would be inserted just once and that value should be displayed in the order grid under the header of the added custom ...

Enumeration of .Net IList

I'd like to know if I can assume that the IEnumerator I get from an IList (by calling the GetEnumerator method from the IEnumerable interface) will give me the items in the order of the list. What do you think? ...

Sorting a range by the order of another list in Excel

I have two tables, like this: Table 1 A 1 FirstPhase 2 SecondPhase 3 ThirdPhase 4 FourthPhase Table 2 A B 1 Item1 FirstPhase 2 Item4 FourthPhase 3 Item2 SecondPhase 4 Item3 ThirdPhase The result I want to achieve after sorting is: A B 1 Item1 FirstPhase 2 Item2 SecondPhase 3 Item3 ThirdPhase 4 Item4 FourthPhase ...

Initialization order with constructors in C++

By instantiating an object in C++ with the following class I get a segmentation fault or aborts, depending on the order declaring member variables. E. g. putting mMemberVar and mAnotherMemberVar after mAnotherCountVar results in a segfault. From this listing I removed a std::ofstream from the member variables, which caused the segmentati...

SQL how to make null values come last when sorting ascending

Hello! I have a SQL table with a datetime field. The field in question can be null. I have a query and I want the results sorted ascendingly by the datetime field, however I want rows where the datetime field is null at the end of the list, not at the beginning. Is there a simple way to accomplish that? ...

Can't insert entries of a many-to-many relationship in Entity Framework in a specific order

Hello, I have a many-to-many relationship between 2 entities in Entity Framework, like here . So, Employees and Projects. At one point, I would like to insert some Projects to a Employees entity in a specific order. By conserving the order I would like to know which was the first preference of the Employees for a Projects entity. The th...

mysql ( innodb )foreign key constraints problems

Hello I am running into a couple of issues while trying to generate foreign keys for my tables in MySql(Innodb). Can you please help me with them ? Referenced tables : *create table entity { PID INT(20) auto inc not null, ENTITYID INT(20) not null, details VARCHAR(100) not null, primary key(PID,ENTITYID) } create table user { ...

MySQL update a sorting index column to move items

If I have the following table & data to allow us to use the sort_index for sorting: CREATE TABLE `foo` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `bar_id` INT(11) DEFAULT NULL, `sort_index` INT(11) DEFAULT NULL, PRIMARY KEY (`id`) ); INSERT INTO `foo` (`bar_id`, `sort_index`) VALUES (1,1),(1,2),(1,3),(1,4), (2,1),(2,2),(2,3),(2...

MySQL - How to ORDER BY RELEVANCE? INNODB Table

I've got about 20,000 rows in an INNODB table called 'cards', so FULLTEXT is not an option. Please consider this table: id | name | description ---------------------------------------------------------- 1 John Smith Just some dude 2 Ted Johnson Another dude 3 Johnathan Todd This guy too...

how to allow user to order columns with wxListCtrl in report mode

with wxListCtrl, how to allow the user to rearrange the column order at runtime ? just like in windows. Tnx, Vertilka ...

How to order by maximum of two column which can be null in MySQL?

create table jobs( id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, ..... salaryminus INTEGER UNSIGNED DEFAULT NULL, salaryplus INTEGER UNSIGNED DEFAULT NULL, ..... ); I want to do something like : Select * from jobs order by maxof(salaryminus, salaryplus) limit 10; maxof(Null,1000) should be 1000, H...

cocos2d in iphone z order

Hi guys, I am working on a game with many sprites in a layer, and once you touch the sprite, it will do something. my problem is the z order issue, most of my sprites are overlapping and when you touch the overlapping sprites, the one behind(i think with the lowest z order) react instead of the one in front. I need to understand more ...

mysql order varchar field as integer

I have a varchar field in my table and I want to sort it. But I need to handle this field as integer. Meaning if sort as text the order is "19,2,20" but I want to get the right order "2,19,20". Can anyone help me? ...

How to write subquery in Criteria

Hi there, I have a SQL like this: Select tbl.id, tbl.name From (select table1.id, table1.name from table1 inner join table2 on table1.id = table2.id order by table2.priority ) tbl group by table1.id order by table1.name What I'm tring to archieve is to first sort (order by table2.priority), and then get the record with table1.i...

django queryset: how to order by a (backwards) related field?

Hi folks! In this situation I have two models, Comment and Score. The relationship is defined in the Score model, like so: class Comment(models.Model): content = TextField() ... class Score(models.Model): comment = models.ForeignKey(Comment) value = models.IntegerField() My question is: How do I construct a queryset ...

Order alphanumerical list in PHP

HI, i need to order a list in PHP that looks like: B1200 120A81 00A12 00A22 C100B C100C ordered list would be: 00A12 00A22 120A81 B1200 C100B C100C I was thinking about splitting each line in multidimensional arrays and order it but i am stuck and maybe theres a completely different way for that. Thanks! ...

dynamically create lambdas expressions + linq + OrderByDescending

how can I create a dynamic lambda expression to pass to use in my orderby function inside linq? I basically want transform "queryResults.OrderByDescending();" in "queryResults.OrderByDescending(myCustomGeneratedLambdaExp);" where myCustomGeneratedLambdaExp shall be a string containning "x => x.name" Thanks ...

Re-order records in gridview/bindingsource

I am using Telerik's WinForms controls and have a radGridView which is bound to a bindingsource to display my data. I would like to expand on the functionality of this a bit to give users an extra way to order the records. I have added two command buttons to the gridview (Up, Down) to help facilitate this functionality. Basically, whe...