这个 sql 在 rails 2.3 中如何查询?

How do this sql query in rails 2.3?

我在 rails 2.3[= 上 ruby 中的控制器中的函数中需要此 sql 查询20=].

SELECT name, created_at AS "date" FROM table1 WHERE created_at = '2015-07-15' ORDER by created_at;

这是因为我在这个之前还有两个查询,它们有一个名为 'date' 的字段,我需要将每个查询连接起来并按名为 'date' 的字段对它们进行排序,并且只有最后一个 table 没有名为 'date'.

的字段

好的,我发现这个解决方案对我有帮助,因为其他人可能需要它..

table1.find_by_sql["SELECT name, created_at AS 'date' FROM table1 WHERE created_at = '2015-07-15' ORDER by created_at"]

然后我可以按'date'..

字段对我所有的查询结果(包括前面的表)进行排序