我有两个名为calendar_colour和user的表,
calendar_colour
(
colour_id int primary key,
colour varchar(15)
)
user
(
id int primary key,
name varchar(30),
color int,
foreign key(color) references calendar_colour(colour_id)
)
Run Code Online (Sandbox Code Playgroud)
在用户的添加功能中,我必须从下拉框中选择一种颜色.但我想使用以前用户尚未采用的颜色填充下拉列表.我尝试使用find命令,但似乎是错误的.
$curColours = $this->EventType->query('select color from event_types');
$this->set('colours', $this->EventType->CalendarColour->find('list',array('conditions'=>array('NOT',array('CalendarColour.colour_id' => $curColours)))));
Run Code Online (Sandbox Code Playgroud)
我使用数组$colours填充下拉框.编写查找命令以找到任何用户未使用的颜色的正确方法是什么.
谢谢.
我的oracle表,"发票"看起来像这样.
INV_NUM CUST_NUM INV_DATE INV_AMOUNT
Run Code Online (Sandbox Code Playgroud)
8000 1000 23-Mar-08 235.89
8001 1001 23-Mar-08 312.82
8002 1001 30-Mar-08 528.1
8003 1000 12-Apr-08 194.78
8004 1000 23-Apr-08 619.44
Run Code Online (Sandbox Code Playgroud)
我需要编写一个select查询,它将显示inv_num,inv_amount和平均inv_amount.预期的输出是这样的.
INV_NUM INV_AMOUNT AVG(INV_AMOUNT)
Run Code Online (Sandbox Code Playgroud)
8000 235.89 378.206
8001 312.82 378.206
8002 528.1 378.206
8003 194.78 378.206
8004 619.44 378.206
Run Code Online (Sandbox Code Playgroud)
我希望AVG函数的值在每一行都重复.我知道AVG函数只返回一行.我尝试此查询时收到错误.
select inv_num,inv_amount,avg(inv_amount) from invoice;
ERROR at line 1: ORA-00937: not a single-group group function
Run Code Online (Sandbox Code Playgroud)
有没有办法让avg值显示在每一行?我需要一些帮助来解决这个问题.谢谢.
如何为 type=>number 的输入表单字段设置最小值。我有一个计数字段,该字段的最小值应设置为 0。