$query = Doctrine_Query::create()
->select('IF(m.sender_id = ?, m.receiver_id, m.sender_id) AS uid', $my_id)
->from('Message m')
->where('m.receiver_id = ? OR m.sender_id = ?', array($my_id,$my_id))
->groupBy('uid')
我无法按'uid'分组,好像AS uid根本不工作......
如果我尝试通过 - > getSqlQuery()检索生成的sql并直接在Mysql中试用它,它就可以工作。
SELECT IF(s.sender_id = 1, s.receiver_id, s.sender_id) AS s__0
FROM message s
WHERE (s.receiver_id = 1 OR s.sender_id = 1) GROUP BY s__0
答案 0 :(得分:0)
proc sql;
create view have_sorted_by_month_year as
select
put(date,monname3.) as month_name,
year(date) as year,
percent
from have
order by month(date), year(date);
quit;
proc transpose data=have_sorted_by_month_year out=want(drop=_name_);
by month_name notsorted;
var percent;
id year;
run;
proc print data=want;
run;
----------------------------------
month_
Obs name _2015 _2016 _2017 _2018 _2019
1 Jan 0.201501 0.201601 0.201701 0.201801 0.201901
2 Feb 0.201502 0.201602 0.201702 0.201802 0.201902
3 Mar 0.201503 0.201603 0.201703 0.201803 0.201903
4 Apr 0.201504 0.201604 0.201704 0.201804 0.201904
5 May 0.201505 0.201605 0.201705 0.201805 0.201905
6 Jun 0.201506 0.201606 0.201706 0.201806 0.201906
7 Jul 0.201507 0.201607 0.201707 0.201807 0.201907
8 Aug 0.201508 0.201608 0.201708 0.201808 0.201908
9 Sep 0.201509 0.201609 0.201709 0.201809 0.201909
10 Oct 0.201510 0.201610 0.201710 0.201810 0.201910
11 Nov 0.201511 0.201611 0.201711 0.201811 0.201911
12 Dec 0.201512 0.201612 0.201712 0.201812 0.201912