Hello all
I have a query like this where I want to display sorted records in a paginated format.
This is my query.
SELECT * FROM answers
WHERE userid = '10'
ORDER BY votes LIMIT 10, 20
The two arguments to LIMIT will be used for generating page-by-page display of records. Now, my problem is ORDER BY. How does MySQL execute this quer...
Hey, I want to make this return the result, but in descending order. Is that possible?
var newList = list.OrderBy(x => x.Product.Name).toList();
I thought I could just add descending, like I do in other cases, but it is not accepting that.
...
Hi. I have a problem in T-SQL that I find difficult to solve.
I have a table with groups of records, grouped by key1 and key2. I order each group chronologically by date. For each record, I want to see if there existed a record before (within the group and with lower date) for which the field "datafield" forms an allowed combination wit...
I'm running into a very strange issue that I have found no explanation for yet. With SQL Server 2008 and using the GROUP BY it is ordering my columns without any ORDER BY specified. Here is a script that demonstrates the situation.
CREATE TABLE #Values ( FieldValue varchar(50) )
;WITH FieldValues AS
(
SELECT '4' FieldValue UNION AL...
I have a table like this:
id number otherfields
-------------------------------------------
664 48 aaa
665 49 bbb
666 55 ccc
667 48 ddd
My query groups by the number field, and I want it to pick the first (lowest) id, so that the data comes out like ccc,aaa,bbb (when ordered by numb...
Hello. I'm trying to make a query to retrieve the region which got the most sales for sweet products. 'grupo_produto' is the product type, and 'regiao' is the region. So I got this query:
SELECT TOP 1 r.nm_regiao, (SELECT COUNT(*)
FROM Dw_Empresa
WHERE grupo_produto='1' AND
cod_regiao = d.cod_regiao) as total
...
I have a table full of entries with DATETIME time stamps, and an ID field. I want to make a MySQL query (in my PHP script) that selects from another table with the matching ID. I want to make some kind of join that will sort by the number of entries in the first table with a timestamp more recent than 24 hours. So basically, if there are...
How do I sort the inner collection of an object returned by the entity framework?
public class X
{
public string Field {get; set;}
public EntityCollection<Y> Ys {get; set;}
}
public class Y
{
public string Field {get; set;}
}
from x in entities.Xs
orderby x.Field
select x
Is there a way to modify this LINQ query to return t...
Is it possible to sort a result set by some column and also by RAND()?
For example:
SELECT `a`, `b`, `c`
FROM `table`
ORDER BY `a` DESC, RAND()
LIMIT 0, 10
Thank you.
...
How can I add an order by users_friends.date_created that governs both select queries.
Here is my MySQL code.
(SELECT A.user_id, A.friend_id, B.username, B.avatar
FROM users_friends AS A
INNER JOIN users AS B
ON A.friend_id = B.user_id
AND A.user_id = 3
AND A.friendship_status = 1)
UNION
(SELECT A.friend_id, A.user_id, B.username,...
I am using the following SQL to select records from MySQL database:
SELECT * FROM cms_product WHERE id IN (3,22,1);
The results order equals "ORDER BY id ASC", so as in example records 1,3,22 are returned. How can I get them ordered in the exact way as typed in IN clause? So ordered as 3,22,1 ? Thank you.
...
I am working on a django-nonrel app in Google App Engine.
I am trying to return items from a database in a random order. So I might have 100 items in my Items model. I wish to return a random selection of 20 items.
I have tried using:
Items.objects.order_by('?')[:20]
Except I get the following error:
Randomized ordering isn't s...
Hi
I have a for loop where i want to orderby the name alphabetically
a
b
c
d
looking how to do this, wondered even if i could use linq orderby inside the forloop?
...
Hi there!
I hop there's a simple solution for this:
I have a table where each row has it's own status (SET type field). Statuses can be:
offline
available
busy
distance
I'd like to order as follows
available
busy
distance
offline
I thought a simple
ORDER BY `status` ASC
will do the trick (alphabetical order) but it gives me ...
Using google app engine and Django non-rel, I'm querying a list of movies and want to order them alphabetically.
movies = Movie.objects.all().order_by("title")
The problem is for any titles that do not start with an uppercase character is not following the same sort pattern.
So if queried these movies and returned them sorted then "i...
I've tried looking for the answer, and read many threads on this site, but still can't find the answer I'm looking for.
I am trying to sort a series of numbers that are real look-ups and also one * which isn't, I can sort fine when I don't need to add the fake * but not after.
I have tried
SELECT DISTINCT MasterTable.ClassName, Master...