order-by

LINQ: orderby with dynamic string parameter

HI, i want to do this: orderby = "Nome, Cognome desc"; var timb = time.Timbratures.Include("Anagrafica_Dipendente").Where(p => p.CodDipendente == 1); if(orderBy != "") timb = timb.OrderBy(orderBy); Is there any method for pass a string parameter to Orderby thanks ...

Zendframework / PgSQL fetchAll orderby

i have a pgsql table with fields id, identifier, name. id serial NOT NULL, identifier character varying(16), name character varying(128) I want to fetchAll values from the table orderby identifier. but identifier is having values 12, 100, 200, 50 and after $table->fetchAll(null, 'identifier'); is giving the result 100, 12, ...

How to OrderBy on a generic IEnumerable (IEnumerable<T>) using LINQ in C#?

In my generic repository I have below method: public virtual IEnumerable<T> GetAll<T>() where T : class { using (var ctx = new DataContext()) { var table = ctx.GetTable<T>().ToList(); return table; } } T is a Linq to Sql class and I want to be able to OrderBy on a particular property (i.e. int SortOrder). S...

Numeric Order By In Transact SQL (Ordering As String Instead Of Int)

I have an issue where I am trying to order a result set by what I believe to be a numberic column in my database. However when I get the result set, It has sorted the column as if it was a string (So alphabetically), instead of sorting it as an int. As an example. I have these numbers, 1 , 2, 3, 4, 5, 10, 11 When I order by in Trans...

Order a List (C#) by many fields?

Hi everyone, I want to order a List of objects in C# by many fields, not just by one. For example, let's suppose I have a class called X with two Attributes, A and B, and I have the following objects, in that order: object1 => A = "a", B = "h" object2 => A = "a", B = "c" object3 => A = "b", B = "x" object4 => A = "b", B = "b" and I ...

Excel and SQL, order by help

Im stuck in Excel 2007, running a query, it worked until I wanted to add a 2nd row containing "field 2". Select "Site Updates"."Posted By", "Site Uploaded"."Site Upload Date" From site_info.dbo."Site Updates" Where ("Site Updates"."Posted By") AND "Site Uploaded"."Site Upload Date">={ts '2010-05-01 00:00:00'}), ("Site Location"='Chicago...

mySQL ORDER BY ASC works, DESC does not...

I've "integrated" SMF into Wordpress by querying the forum for a list of the most recent videos from a specific forum board and displaying them on the Wordpress homepage. However when I add the ORDER BY clause, the query (which I tested on other parts of the same page successfully), breaks. To add to the mix, I am using the Auto Embed ...

MySQL Order By not using ASC or DESC

I have a column using IDs that I want to sort by. It has ID values from 1 to 3. However, instead of just using ASC of DESC, I want to do a custom sort by 2, 3, 1. How do I make this happen? ...

How do you keep the order using SELECT WHERE IN()?

Is there a way to keep the order when using SELECT WHERE IN()? For example, using the following query: SELECT id FROM data_table WHERE id IN(56,55,54,1,7); The results will come back using the default order by id. 1,7,54,55,56 When I want to keep the order used in the IN: 56,55,54,1,7 Is there a quick way to do this in mySQL or will...

Ordering by number of rows?

Alright, so I have a table outputting data from a MySQL table in a while loop. Well one of the columns it outputs isn't stored statically in the table, instead it's the sum of how many times it appears in a different MySQL table. Sorry I'm not sure this is easy to understand. Here's my code: $query="SELECT * FROM list WHERE added='...

NHibernate + Paging + Ordering

I'm not quite sure of the most elegant solution for what I am trying to do. I have a page which lists music listings, there can be thousands of these so they are paged in batches of 20, I also have 4 links at the top of the page to change the way these listings are ordered. The sort by properties could be located on different entities ...

GROUP BY a date, with ordering by date.

Take this simple query: SELECT DATE_FORMAT(someDate, '%y-%m-%d') as formattedDay FROM someTable GROUP BY formatterDay This will select rows from a table with only 1 row per date. How do I ensure that the row selected per date is the earliest for that date, without doing an ordered subquery in the FROM? Cheers ...

how to use the order by and aggregate function together in sql query

SELECT count(distinct req.requirementid), req.requirementid, org.organizationid, req.locationofposting, org.registereddate FROM OrganizationRegisteredDetails AS org, RequirementsDetailsforOrganization AS req WHERE org.organizationid = req.requirementid ORDER BY org.RegisteredDate desc this shows me the error...

Simple SELECT query problem...

Hi, I have this MySql select query which seems to have a bug but I am quite "green" so I simply cannot see, so maybe you could help? Here is the query: SELECT node_id FROM rate WHERE node_id='".$cat_node_id_string."' LIMIT ".$node_count_star.",".$node_count_end." ORDER BY SUM(amount) GROUP BY node_id Thanks for help in ...

Complex data ordering...

Hi, I have one tables ids in an array and they are ordered in the way I want and I have to select data from another table using those ids and in a order they are listen in the array. Pretty confusing but I was thinking of two solutions giving ORDER BY parameter the array but I do not know if that possible and another is to get all the ne...

Doing order by using the Jaro-Winkler distance algorithm?

I am wondering how would I be able to run a SQLite order by in this manner select * from contacts order by jarowinkler(contacts.name,'john smith'); I know Android has a bottleneck with user defined functions, do I have an alternative? ...

Using django and django-voting app, how can I order a queryset according to the votes of each item?

(I'm new to python and django so please bear with me for a second. I apologise if this has been answered elsewhere and couldn't find it) Let's say I have a Link model and through the django-voting application users can vote on link instances. How can I order those link instances according to their score, eg. display those with the highe...

how so select similarities in MySQL?

Currently, I am doing a search function. Lets say in my database, I have this data: Keyword1 Keyword2 Keyword3 Keysomething Key and the user entered: "Key" as the keyword to search. This is my current query: Q1: SELECT * FROM data WHERE (data_string LIKE '$key%' OR data_string LIKE '%$key%' OR data_string LIKE '...

Alternatives to sign() in sqlite for custom order by

I have a string column which contains some numeric fields, but a lot are 0, empty string or null. The rest are numbers having different range, all positive. I tried to create a custom order by. The order would be done by two fields. First I would like to order the fields that have this number >0 and then sort by name. So something this...

How To determine the order data is read from a MYSQL Database?

is there a way to change the order data from a DB are read ? you know , the default order is that they are read from the first data inserted to the latest so is there a way to change it to latest->first? ...