首页 \ 问答 \ 分组月份和年份时的外部参考错误(Outer Reference error when grouping month and years)

分组月份和年份时的外部参考错误(Outer Reference error when grouping month and years)

出现以下错误:

Each GROUP BY expression must contain at least one column that is not an outer reference

我想列出按设施,月份和年份分组的calculatedDrugDistributionHistory列表。 我只想了解哪些设施已经导入我们的系统。

我有这个问题:

select 
    f.name,
    MONTH(cddh.dateGiven) as 'date_month',
    YEAR(cddh.dateGiven) as 'date_year' 
from 
    calculatedDrugDistributionHistory cddh
        inner join facilityIndividuals fi on fi.facilityIndividualId = cddh.facilityIndividualId
        inner join facilities f on fi.facilityId = f.facilityId
group by 
    f.name,
    'date_month',
    'date_year'
order by
    f.name,
    'date_month',
    'date_year'

Getting the following error:

Each GROUP BY expression must contain at least one column that is not an outer reference

I'd like to have a listing of calculatedDrugDistributionHistory grouped by facilty, month, and year. I just want to take inventory of which facilities for which months have been imported into our system.

I have this query:

select 
    f.name,
    MONTH(cddh.dateGiven) as 'date_month',
    YEAR(cddh.dateGiven) as 'date_year' 
from 
    calculatedDrugDistributionHistory cddh
        inner join facilityIndividuals fi on fi.facilityIndividualId = cddh.facilityIndividualId
        inner join facilities f on fi.facilityId = f.facilityId
group by 
    f.name,
    'date_month',
    'date_year'
order by
    f.name,
    'date_month',
    'date_year'

原文:https://stackoverflow.com/questions/17859310
更新时间:2023-10-25 22:10

最满意答案

执行级别顺序遍历(使用队列)。

每当您出列时,对于您所在的级别,请检查它是否是您迄今为止记录的最小值或最大值。

在检查最小值和最大值时,请确保root不同时root.left和root.right为NULL


Perform level-order traversal (using queues).

Every time you dequeue, for the level in which you're, check if it's the smallest or the largest value that you've recorded so far.

While checking for the smallest and largest values, make sure root doesn't have both root.left & root.right as NULL

相关问答

更多
  • 具体的解决方案取决于子树的定义。 考虑以下BST: 5 3 2 4 8 - 9 我们想要找到范围[4,8]的子树。 很显然, 4节点属于输出。 但是另一半树呢? 如果一个子树引用一个包含所有子节点的节点,那么这就是整个结果。 如果子树实际上是输入节点的子集,则节点5和8属于结果,但它们与3和9节点的连接必须被剥离。 无论如何,以下算法都可以处理这两种情况。 预处理器定义WHOLE_SUBTREES定义子树是否是全部子组件的全部子组件。 static List
  • 这是一个古老的技巧,它仍然有效: keep the back pointers in the call stack. struct stacked_list{ struct stacked_list* prev; struct tree* tree; }; void printpath_helper(int data, struct stacked_list* path) { if (!path->prev) printf("%d ...
  • 我认为第一个选项是最快的,它只需要O(1)空间来实现这一点。 但是,无论何时插入/删除项目,都需要不断更新此值。 获取所有节点的数量需要O(1)时间。 第二种选择会使这个程序变得太复杂,因为在某处删除/插入一个节点必须更新它的所有祖先。 您可以添加父指针,以便可以充分更新每个祖先,或者您需要遍历树中的所有节点并再次更新数字。 无论如何,我认为这将是三者中最糟糕的选择。 第三个选项是好的,如果你不多次调用,因为第一个选项比这个选项快很多,O(1)。 这将需要O(n),因为您需要遍历每个节点来检查计数。 就你的 ...
  • package com.gati.dsalgo.string; class BST { BSTNode root; public BST() { root = null; } void insertNames(int data, String name, double salary) { root = insertNames(root, data, name, salary); } BSTNode insertName ...
  • 执行级别顺序遍历(使用队列)。 每当您出列时,对于您所在的级别,请检查它是否是您迄今为止记录的最小值或最大值。 在检查最小值和最大值时,请确保root不同时root.left和root.right为NULL Perform level-order traversal (using queues). Every time you dequeue, for the level in which you're, check if it's the smallest or the largest value tha ...
  • root指向树的顶部节点。 在你改变其价值的同时。 你必须使用anoter变量(比如'n')。 'n'的初始值是'root'。 在一段时间内你只使用'n'。 if(root == null){ root = newNode; return root; } else{ Node n = root; while(n != null){ ... } return root; ...
  • 要在列表中存储树 - 您至少需要两个列表:一个用于预订遍历,另一个用于按顺序遍历。 幸运的是 - 由于树是BST,有序遍历只是排序列表。 因此,您可以存储预订遍历(您可以尝试就地执行)并通过在重构中对元素进行排序,您可以获得有序遍历。 这篇文章讨论了如何从inorder和pre-order遍历它重建树。 I think I found the solution myself: below is the complete Java implementation The logic + pseudo Code ...
  • 你为什么不在飞行中进行顺序遍历和计数? 你需要一个全局变量来跟踪最后一个数字,你需要将它初始化为一个不小于第一个数字的东西(例如树的根)。 我的意思是: // Last item int last; // Recursive function for in-order traversal int countPairs (whichever_type treeRoot) { int r = 0; // Return value if (treeRoot.leftChild != null) ...
  • BST类是节点。 首先,确定null元素是否小于或大于非null元素。 要实现插入,您需要执行以下操作: 1)验证element参数不为null。 如果为null,则不执行任何操作。 2)未完成的代码必须决定插入元素的位置。 a)如果其中一个孩子为空,那么在插入后,两个孩子都不会为空。 将新元素与非null元素进行比较; 这两个人中较大的一个是正确的孩子。 b)如果两个子节点都不为null,则确定放置新元素的位置(小于左侧,使用左侧。大于左侧,使用右侧)并调用该元素的插入。 注意:如果你还没有注意到,这个赋 ...
  • 而不是使用临时变量来保存前一个节点 - 这只能用于深度为1 - 而是在子节点上调用相同的函数 。 递归树遍历可能看起来像这样: public int countSomething (Node node) { // Self; // int result = 1; // use your required logic here // Children; // if (node.left != null) result += ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。