sql-order-by

odoo Qweb report lines in alphabetical order

戏子无情 提交于 2019-12-11 09:53:22
问题 I'm getting crazy for what I believe it is a really silly matter. I need to render the result of an array in alphabetical order: <tr t-foreach="o.order_line" t-as="l"> <td> <span t-field="l.name"/> </td> should I use a SQL query SELECT * FROM table ORDER BY l.name DESC ? but it seams too complicated, I have the feeling there is a simple condition to render it correctly... any help highly appreciated! Thanks! 回答1: Have a look at this You could set a new variable to order_line.sorted() and then

Mysql order number / character combined

夙愿已清 提交于 2019-12-11 09:35:22
问题 I have a SQL table with in a product-name field with the following values: 10b 9b 8b 7b 6b 5b 4b 3b 2b 1b These needs to be ordered from 1 to 10, but for some reason when i select with the following order: ORDER BY title ASC , then i get: 10b 1b 2b 3b 4b etc.. But that 10 needs to be after the 9, not before the 1, how is this possible? Thank you, Kind regards 回答1: SELECT CAST(title AS UNSIGNED INTEGER) AS ORDER_FIELD ,title ORDER BY ORDER_FIELD ASC 来源: https://stackoverflow.com/questions

Multiple column in order by clause - mysql

你。 提交于 2019-12-11 08:56:40
问题 I have two columns in a table say, LIKE and FAVORITES (int value) See the chart: ╔════╦══════╦══════════╗ ║ ID ║ LIKE ║ FAVORITE ║ ╠════╬══════╬══════════╣ ║ 1 ║ 25 ║ 9 ║ ║ 2 ║ 5 ║ 17 ║ ║ 3 ║ 6 ║ 1 ║ ║ 4 ║ 45 ║ 0 ║ ║ 5 ║ 3 ║ 44 ║ ╚════╩══════╩══════════╝ Now, I want to select the Maximum Like and Favorites IDs from the SELECT clause. I have tried SELECT ID from TABLE WHERE CONDITION ORDER BY LIKE,FAVORITES DESC But the result shows the rows based on LIKE DESC order. The result should be ╔════

How to sort rows by ON, OFF, SOLD

房东的猫 提交于 2019-12-11 08:34:25
问题 I have followings 3 values that could be in a row in database - ON , OFF , SOLD (column sort_it ). When I set the sort clausule on ORDER BY sort_it ASC , so I will get the items with a value in the sort_in column OF , then ON and SOLD . But I need the sequence ON , OFF , SOLD . Exist any way to do it somehow? I mean... edit a way saving data into database will be demanding, so I would do this in the last moment. 回答1: Yes you can use custom data sortings like this: SELECT * FROM table ORDER BY

Dynamic Linq OrderBy null error

纵然是瞬间 提交于 2019-12-11 07:54:15
问题 I'm using dynamic Linq to order a result set depending on which column is passed in. I'm using this to order a table when a user clicks on a table column. If the property im ordering on is a class which is null the code falls over, i want to be able to dynamically orderby a string but cater for nulls if the property is a class. This is the code from the System.Linq.Dynamic class im using. public static IQueryable OrderBy(this IQueryable source, string ordering, params object[] values) { if

What options do I have to make my ORDER BY faster?

喜你入骨 提交于 2019-12-11 07:38:40
问题 I have the following query: SELECT DISTINCT c.id FROM clients AS c LEFT JOIN client_project AS cp ON (cp.client_id = c.id) WHERE cp.project_id = 1 AND c.active_flag = 1 ORDER BY c.client_name If I remove the order by, the query takes 0.005 seconds. With the order by, the query takes 1.8-1.9 seconds. I have an index on client_name . What else would improve the speed? Edit: c.id is primary key, but there could be multiple records for it in client_project and therefore it may result in more than

Fluent NHibernate Order by Property in related Entity

江枫思渺然 提交于 2019-12-11 06:59:22
问题 I have 2 tables in my database: CREATE TABLE [items]( [item_id] [int] IDENTITY(1,1) NOT NULL, [item_name] [varchar](50) NOT NULL, [group_id] [int] NOT NULL ) CREATE TABLE [itemgroup]( [group_id] [int] IDENTITY(1,1) NOT NULL, [group_name] [varchar](50) NULL ) and here are mapping classes for these entities: public class ItemMap : ClassMap<Item> { public ItemMap() { Table("items"); Id(x => x.Id).Column("item_id"); Map(x => x.Name).Column("item_name"); References(x => x.ItemGroup).Column("group

ORACLE Query with ORDER BY and UNION

拈花ヽ惹草 提交于 2019-12-11 06:48:48
问题 I have the following Query which works great! The only thing is that I need the result set in DESC Order and the following ORDER BY Clause that I have appended to the end of my Query generates the following Oracle Error: ORA-00933: SQL command not properly ended 00933. 00000 - "SQL command not properly ended" *Cause: *Action: Error at Line: 46 Column: 54 Here is the Query. Again, this query works. It is just that when I add the following line: FINAL_SEARCH order by FINAL_SEARCH.DOC_HDR_ID

Unexpected effect of filtering on result from crosstab() query

不羁岁月 提交于 2019-12-11 06:47:52
问题 I have a crosstab() query like the following: SELECT * FROM crosstab( 'SELECT row_name, extra1, extra2..., another_table.category, value FROM table t JOIN another_table ON t.field_id = another_table.field_id WHERE t.field = certain_value AND t.extra1 = val1 ORDER BY row_name ASC', 'SELECT category_name FROM category_name WHERE field = certain_value' ) AS ct(row_name text, extra1 text, extra2 text, ...) Simplified example, the actual query is really complex and contains important information.

Dynamic Order By On Date With Entity Framework and Linq

大憨熊 提交于 2019-12-11 05:53:25
问题 I had another question similar answered here on NULL values being last on an order by. Keep NULL rows last on Dynamic Linq Order By I would also like to see if I can do the same thing with a Date column with the following criteria. All items with all end dates on the current date and up at the top, sorted by the most recent upcoming event Followed by all past events using the end date and comparing to the current date with the most recent end date passed and down. I do something similar in