首页 \ 问答 \ 如何在Oracle中的一个条件HAVING和AND中组合(How to combine in one condition HAVING and AND in Oracle)

如何在Oracle中的一个条件HAVING和AND中组合(How to combine in one condition HAVING and AND in Oracle)

我想知道如何处理一个条件,例如:

select count(s.id) from card c
                  join subject s on c.ean=s.ean
                  join account a on s.id=a.owner_subject
                 where a.status_external=0
                   and a.status_internal=0
                   and s.type=0
having( 
( trunc(max(s.hist_modified_tmsp))<=last_day(add_months(trunc(sysdate,'mm'),-1)) and level=1 )  
or  
( trunc(min(s.hist_modified_tmsp))<=last_day(add_months(trunc(sysdate,'mm'),-1)) and level=2 ) )

我的Oracle告诉我“不是GROUP BY Expression”。 有什么想法吗? 我将非常感谢任何帮助,谢谢


I wonder how can I put in one condition having and for example:

select count(s.id) from card c
                  join subject s on c.ean=s.ean
                  join account a on s.id=a.owner_subject
                 where a.status_external=0
                   and a.status_internal=0
                   and s.type=0
having( 
( trunc(max(s.hist_modified_tmsp))<=last_day(add_months(trunc(sysdate,'mm'),-1)) and level=1 )  
or  
( trunc(min(s.hist_modified_tmsp))<=last_day(add_months(trunc(sysdate,'mm'),-1)) and level=2 ) )

My Oracle tells me "Not a GROUP BY Expression". Any ideas please? I will be very grateful for any help, thank you


原文:https://stackoverflow.com/questions/26997327
更新时间:2023-11-29 11:11

最满意答案

简而言之:是的,动态创建的函数就像在运行时创建的任何其他Python对象一样创建。

更长的答案:对于垃圾收集器管理的资源,例如没有绑定到外部资源的对象,Python和PyGTK将正确处理未使用的对象。 对于外部资源(如打开文件或正在运行的线程),您需要采取措施确保正确清理。 要准确回答您的问题,查看具体代码会很有用。 通常,以下内容适用于Python和GTK:

  • Python对象(包括动态创建的函数)在无法再从Python访问之后的一段时间内被释放。 在某些情况下,在对象无法访问后立即发生释放(如果对象不参与引用循环),而在其他情况下,您必须等待垃圾收集器启动。

  • 销毁窗口小部件会立即清除与窗口小部件关联的GTK资源。 对象本身可以保持活着。 通过窗口小部件可以访问的回调应该立即解除引用,并且如果没有其他任何东西从Python中保留,很快就会被解除分配。

您可以使用weakref模块中的弱引用类型来测试它。 例如:

>>> import gtk
>>> 
>>> def report_death(obj):
...     # arrange for the death of OBJ to be announced
...     def announce(wr):
...         print 'gone'
...     import weakref
...     report_death.wr = weakref.ref(obj, announce)
... 
>>> def make_dynamic_handler():
...     def handler():
...         pass
...     # for debugging - we want to know when the handler is freed
...     report_death(handler)
...     return handler
... 
>>> w = gtk.Window()
>>> w.connect('realize', make_dynamic_handler())
10L
>>> w.destroy()
gone

现在,如果您将代码更改为handler以包含循环引用,例如通过修改它来提及自己:

def handler():
    handler      # closure with circular reference

...对destroy的调用将不再导致立即打印 - 这将要求程序继续工作,或者显式调用gc.collect() 。 在大多数Python和PyGTK程序中,自动释放“只是工作”,你不需要努力来帮助它。

最终,唯一可靠的测试是否存在内存泄漏是在无限循环中运行可疑代码并监视进程的内存消耗 - 如果它无限制地增长,则某些内容不会被释放并且您有内存泄漏。


In short: yes, it does, dynamically created functions are created just like any other Python objects created during run-time.

Longer answer: For resources managed by the garbage collector, such as objects not tied to an external resource, Python and PyGTK will correctly dispose of unused objects. For external resources, such as open files or running threads, you need to take steps to ensure their correct cleanup. To answer your question precisely, it would be useful to see concrete code. In general, the following things apply to Python and GTK:

  • Python objects, including dynamically created functions, are deallocated some time after they can no longer be reached from Python. In some cases deallocation happens immediately after the object becomes unreachable (if the object is not involved in reference cycles), while in others you must wait for the garbage collector to kick in.

  • Destroying a widget causes GTK resources associated with the widget to be cleared immediately. The object itself can remain alive. Callbacks reachable through the widget should be dereferenced immediately and, provided nothing else holds on to them from Python, soon deallocated.

You can use the weak reference type from the weakref module to test this. For example:

>>> import gtk
>>> 
>>> def report_death(obj):
...     # arrange for the death of OBJ to be announced
...     def announce(wr):
...         print 'gone'
...     import weakref
...     report_death.wr = weakref.ref(obj, announce)
... 
>>> def make_dynamic_handler():
...     def handler():
...         pass
...     # for debugging - we want to know when the handler is freed
...     report_death(handler)
...     return handler
... 
>>> w = gtk.Window()
>>> w.connect('realize', make_dynamic_handler())
10L
>>> w.destroy()
gone

Now, if you change the code to handler to include a circular reference, e.g. by modifying it to mention itself:

def handler():
    handler      # closure with circular reference

...the call to destroy will no longer cause gone to be immediately printed - that will require the program to keep working, or an explicit call to gc.collect(). In most Python and PyGTK programs automatic deallocation "just works" and you don't need to make an effort to help it.

Ultimately, the only reliable test whether there is a memory leak is running the suspect code in an infinite loop and monitoring the memory consumption of the process - if it grows without bounds, something is not getting deallocated and you have a memory leak.

相关问答

更多
  • 现在,我认为这还没有准备好。 但是,您仍然可以通过手动内省来查看Gtk-3.0.gir文件(位于位于/usr/share/gir-1.0/Gtk-3.0.gir系统中)。 gir文件只是一个xml文件,无论您使用的编程语言如何,都应该精确地使用它来浏览公开的界面。 例如, Label类可以找到
    其实,阅读Dialog.run()的文档 。 该对话不会自动销毁。 如果你在run()方法退出时hide()它,那么你应该可以多次run()它。 或者,您可以将对话框设置为构建器文件中的模式,然后仅show()它。 这将实现类似的效果,但与run()不完全相同 - 因为run()创建主GTK循环的第二个实例。 编辑 如果您没有连接到delete-event信号,则得到分段错误的原因是您要点击关闭按钮两次。 以下是发生的情况: 你点击“运行对话框”,这会调用对话框的run()方法。 模态对话框出现,并启动它自 ...
  • 不,那里没有。 如果切换到Python 3并from gi.repository import Gtk ,那么您可以使用Broadway在浏览器中运行GTK应用程序。 但是,这仅适用于本地,而非网站。 No, there is not. If you switch to Python 3 and from gi.repository import Gtk, then you can use Broadway to run a GTK application in your browser. However, ...
  • 可能是你想问的问题已经被@DonQuestion回答了...但是如果你真的只是想问为什么help(gtk.Label.get)没有回复帮助...答案其实很简单:因为Label对象中的get方法在源代码中缺少docstring。 :) 实际上,对help的调用不会产生错误,只是一个空的答案。 It might be that what you wanted to ask was answered by @DonQuestion already... however if you truly just want ...
  • 简而言之:是的,动态创建的函数就像在运行时创建的任何其他Python对象一样创建。 更长的答案:对于垃圾收集器管理的资源,例如没有绑定到外部资源的对象,Python和PyGTK将正确处理未使用的对象。 对于外部资源(如打开文件或正在运行的线程),您需要采取措施确保正确清理。 要准确回答您的问题,查看具体代码会很有用。 通常,以下内容适用于Python和GTK: Python对象(包括动态创建的函数)在无法再从Python访问之后的一段时间内被释放。 在某些情况下,在对象无法访问后立即发生释放(如果对象不参与 ...
  • 每个信号都有一些参数传递给连接的信号处理程序。 查看文档以查看它们是什么。 例如,您可以看到Gtk.Button的clicked信号接收按钮本身作为参数。 您的信号处理程序的参数数量必须与这些参数匹配,并且如果它是方法,则包括self 。 所以B1的正确定义是: def B1(self, button): 在某些情况下,你实际上可能不关心传递给信号处理程序的值。 在这种情况下,您可以执行以下操作: def B1(self, *args): 这在文档中解释。 Each signal has certain ...
  • 它应该是folderView = FolderView() 。 请参阅以下交互式提示结果: >>> from gtk import TreeView >>> class FolderView(TreeView): ... pass ... >>> fw = FolderView() >>> from gtk import HBox >>> hbox = HBox() >>> hbox.add(FolderView) # this is passing the class Traceback (mo ...
  • 这是我目前的。 随意使用它,或者提出更好的建议: class HandlerFinder(object): """Searches for handler implementations across multiple objects. """ # See for why this is # necessary. def __init__(self, backing_objec ...
  • 只需使用空元组作为第三个参数。 __gsignals__ = { "some-signal": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ()), } Just use an empty tuple as the third argument. __gsignals__ = { "some-signal": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ()), }
  • C库需要知道参数的C类型,对于Gtk,Gdk,Gio和GLib对象,包装器中的类型将起作用,因为它们镜像Gtk和族库中的C类型。 但是,对于任何其他类型,您需要传递object或gobject.TYPE_PYOBJECT 。 这意味着在C方面传递了“python对象” 类型 。 从python脚本可访问的每个对象都属于该类型,这几乎意味着任何可以通过python脚本传递的object都适合object参数。 当然,这也意味着此功能在python中不起作用! Python依赖于duck typing ,这意味 ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)