首页 \ 问答 \ oracle sql如何按功能分组选择特定的不同集合(oracle sql how to select specific distinct set in group by function)

oracle sql如何按功能分组选择特定的不同集合(oracle sql how to select specific distinct set in group by function)

--------------------------------------------------
| Col1               | Col2                      |
--------------------------------------------------
| A                  | 1                         |
--------------------------------------------------
| A                  | 2                         |
--------------------------------------------------
| A                  | 3                         |
--------------------------------------------------
| B                  | 3                         |
--------------------------------------------------
| B                  | 4                         |
--------------------------------------------------
| B                  | 5                         |
--------------------------------------------------
| C                  | 4                         |
--------------------------------------------------
| C                  | 6                         |
--------------------------------------------------
| C                  | 3                         |
--------------------------------------------------

如何选择具有3和4的不同col1(答案是B,C)

提前致谢


Table

--------------------------------------------------
| Col1               | Col2                      |
--------------------------------------------------
| A                  | 1                         |
--------------------------------------------------
| A                  | 2                         |
--------------------------------------------------
| A                  | 3                         |
--------------------------------------------------
| B                  | 3                         |
--------------------------------------------------
| B                  | 4                         |
--------------------------------------------------
| B                  | 5                         |
--------------------------------------------------
| C                  | 4                         |
--------------------------------------------------
| C                  | 6                         |
--------------------------------------------------
| C                  | 3                         |
--------------------------------------------------

how to select distinct col1 that has 3 and 4 (answer is B, C)

Thanks in advance


原文:https://stackoverflow.com/questions/20229776
更新时间:2023-11-07 13:11

最满意答案

虽然我不是100%肯定我认为boolean []仍然使用每个条目约1个字节。 Max可能会变得非常大,所以即使增加JVM的内存也可能无法解决问题。 但是,你可以做的一件事是不使用布尔[]而是使用BitSet ,这样你每个数字只能使用1位,因此你可以覆盖直到int的最大值。


Although I'm not 100% sure I think a boolean[] still uses about 1 byte per entry. Max will probably get quite big so even increasing the memory for the JVM will probably not do the trick. One thing you can do however is not use a boolean[] but a BitSet instead, this way you'll only use 1 bit per number and thus you can probably cover until the max value of int.

相关问答

更多
  • 对于四位数字,可以通过程序详尽地进行验证,但对于n位数字,我们必须在理论上证明它。 For four digit number this can be verified exhaustively through a program but for n digit we will have to prove it theoretically.
  • 你的算法效率不高。 因此,无论您使用哪种数据结构 你不会获得很好的性能提升。 你应该使用另一种算法 被称为'Eratosthenes的筛子'。 尝试实现此算法,您会注意到 性能差异(特别是对于较大的N值)。 目前你 N = 20。 Eratosthenes的筛子 Your algorithm is not efficient. So regardless of which data structure you use you won't get a great performance speed-up. Y ...
  • 你的问题是 for (i = 4; i >= m && i <= n; i += 2) for (i = p*p; i >= m && i <= n; i += p) 如果范围的下限为4或更小,则只消除2的倍数,并且只消除大于sqrt(m)的素数倍数。 从循环条件中删除i >= m部分并将其替换为if (i < m) { continue; } 在循环体中(更好的是,直接计算p的第一个倍数不小于m并完全避免该条件)。 而不是使用't'和'f'作为标志,使用1和0作为DMR意图,这将被更好地理解。 重新更新 ...
  • 虽然我不是100%肯定我认为boolean []仍然使用每个条目约1个字节。 Max可能会变得非常大,所以即使增加JVM的内存也可能无法解决问题。 但是,你可以做的一件事是不使用布尔[]而是使用BitSet ,这样你每个数字只能使用1位,因此你可以覆盖直到int的最大值。 Although I'm not 100% sure I think a boolean[] still uses about 1 byte per entry. Max will probably get quite big so ev ...
  • 如果将upper_bound更改为upper_bound = int(math.sqrt(1000000000))+ 123456 ,则它将传递所有测试用例。 现在,你能算出为什么这样吗? 我会把它作为锻炼给你。 If you change the upper_bound to upper_bound = int(math.sqrt(1000000000)) + 123456, then it will pass all the test cases. Now, can you figure why so? ...
  • 安装nvidia-cuda-toolkit的Apt不安装cuda。 你可以安装cuda格式nvidia的网站 。 (*使用.deb) Apt installing the nvidia-cuda-toolkit does not install cuda. You can install cuda form nvidia's website. (*Use the .deb)
  • 你的数组超出了索引的大值m和n。 在您的系统上尝试此示例测试用例,其中m = 999900000且n = 1000000000。您不能将这些大值存储为数组的索引。 即使是m或n = 10 ^ 8,也会超出数组的边界索引。 Your array goes out of index for large values of m and n. Try this sample test case on your system where m = 999900000 and n = 1000000000. You ca ...
  • 问题是你的isprime功能。 对于以下数字,它错误地返回true : 0,1,4,9,25,49,121,169,289,361,529,841,961,1369,1681,1849,2209,2809,3481,3721,4489,5041,5329,6241,6889, 7921,9409 除0和1 ,所有这些都恰好是素数的平方。 你可以通过改变来解决它 for (int i = 2; i < sqrt(number); i++) { 成 for (int i = 2; i <= sqrt(numb ...
  • 功能是什么价格()? 检查整数是否为素数是一个函数吗? 我想如果你有它,你只需要这样做: for(int i=1; i<=MAX_PRIME; i++) { if(isPrime(i)){ count++ } } return count; What the function isPrice()? is it a function to check that a integer number is prime number or not? I think that ...
  • 获得相对素数的简单方法: 现在,我必须找到这个数字的相对素数 对于整数n ,其中n>2 , n和n-1总是相对素数。 因此,假设n不是2或更小,只需将n-1作为输出,因为它保证相对素数。 如果n等于2,那么你的条件是不可能的。 非平凡的相对素数 如果你想要一个非平凡的解决方案,你总是可以实际计算GCD。 使用欧几里德的方法如下: long findGCD(long l1, long l2) { //end recursion if(l2 == 0){ return numbe ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)