oracle sql-如何在特定范围内获取最大价值的记录

时间:2018-12-05 16:38:10

标签: sql oracle

我需要查询数据库以查找返回HISTOLOGY_NUM的记录:

  1. 具有一列的值:ACTIVITY_TYPE ='His:In Queue'
  2. 和AP_RCVL_ACTIVITY_ID列,其中ACTIVITY_TYPE ='他的:在队列中'在相同数量的HISTOLOGY_NUM中具有最大值

到目前为止,我有一个查询返回的HISTOLOGY_NUM具有最大的AP_RCVL_ACTIVITY_ID的值,但我不知道如何将其合并为需要ACTIVITY_TYPE ='His:In Queue'的

SELECT a.HISTOLOGY_NUM, a.AP_RCVL_ACTIVITY_ID

FROM V_HISTOLOGY_ACTIVITY a

INNER JOIN (

    SELECT HISTOLOGY_NUM, MAX(AP_RCVL_ACTIVITY_ID) AS AP_RCVL_ACTIVITY_ID

    FROM V_HISTOLOGY_ACTIVITY

    GROUP BY HISTOLOGY_NUM 

) b ON a.HISTOLOGY_NUM = b.HISTOLOGY_NUM

1 个答案:

答案 0 :(得分:0)

这将起作用:

type state = string;
type action = 
  | InputChange(string);

let component = ReasonReact.reducerComponent("Input");

let make = (~onSubmit, _children) => {
  ...component,
  initialState: () => "",
  reducer: action => 
    switch (action) {
    | InputChange(text) => ReasonReact.Update(text)
    },
  render: ({state: todo, send}) =>
    <input
      className="input"
      value=todo
      type_="text"
      placeholder="What do you want todo"
      onChange={e => send(ReactEvent.Form.target(e)##value)}
      onKeyDown={
        e =>
          if (ReactEvent.Keyboard.key(e) == "Enter") {
            onSubmit(todo);
            send(() => "");
          }
      }
    />,
};