我有一个小疑问.我有以下查询
SELECT empno
|| '|'
|| ename
|| '|'
|| sal
|| '|'
|| comm
FROM (SELECT empno,
ename,
sal,
comm
FROM emp);
Run Code Online (Sandbox Code Playgroud)
输出结果如下:
7611|Grp Fract|2001|.11
7499|ALLEN WOR|1600|.22
7521|WARD|1250|10.23
7566|JONES|2975|234.23
7654|MARTIN|1250|.98
Run Code Online (Sandbox Code Playgroud)
最后一列COMM的值为0.11,0.22,0.98
但上面的查询返回的数据为.11,.22,.98.当我连接数据以及如何解决这个问题时,任何人都可以帮助我理解为什么会发生这种情况,我需要准确的值,因为它在COMM列中.
o/p应该是
7611|Grp Fract|2001|0.11
7499|ALLEN WOR|1600|0.22
7521|WARD|1250|10.23
7566|JONES|2975|234.23
7654|MARTIN|1250|0.98
Run Code Online (Sandbox Code Playgroud)
通讯列定义为number(7,2).
谢谢
我正在使用Oracle.
假设我有一个包含此样本的表,随机,内容:
columnA | columnB | content
--------------------------------
AfBkxZ | 292 | a
LDglkK | 181 | b
AfBkxZ | 51 | c
AfBkxZ | 315 | d
LDglkK | 808 | e
Cee89g | 1 | f
Run Code Online (Sandbox Code Playgroud)
我想在其中有一个视图,其中我对columnA中的每个值都有一个唯一的编号,并且对于其中columnA具有该值的行内的记录编号.
基于以上样本数据的结果:
Group_number | Record_number | columnB | content
------------------------------------------------
1 | 2 | 292 | a (1.2)
3 | 1 | 181 | b (3.1)
1 | 1 | 51 | c (1.1)
1 | 3 | 315 | d (1.3) …Run Code Online (Sandbox Code Playgroud) 如果我有一个包含数据的表格数字:
+------+------+------+------+
| colA | colB | colC | colD |
+------+------+------+------+
| 1 | 2 | 3 | 4 |
| 1 | 2 | 9 | 5 |
+------+------+------+------+
Run Code Online (Sandbox Code Playgroud)
并做:
select colA, colB, colC, MAX(colD) FROM Numbers GROUP BY colA, colB;
Run Code Online (Sandbox Code Playgroud)
我相信它应该返回第2行.它分组colA, colB并选择最大的一个colD.
不幸的是,这不起作用,因为你还必须按照colC进行分组才能返回它.
为什么?有没有其他方法可以做我想做的事情?
我想在同一行colA和colB,但最大的中的一个colD.
是否可以在单个查询中执行此操作:
CREATE TABLE foo(bar INTEGER);
COMMENT ON foo IS 'my foo table';
COMMENT ON bar IS 'my bar column of the foo table';
Run Code Online (Sandbox Code Playgroud)
像约束的东西:
CREATE TABLE foo
( bar INTEGER COMMENT IS 'my bar column of the foo table'
, COMMENT IS 'my foo table'
);
Run Code Online (Sandbox Code Playgroud)
?
我是sql的新手,我正在努力创建一个查询.我有一张桌子Dept_Employee
DeptId EmployeeId Salary JoinDate (DD-MM-YYYY)
------------------------------------------------------------
1 77 8787 11-09-2010
1 87 9877 12-08-2011
1 76 9544 08-11-2010
2 33 9999 12-05-2010
Run Code Online (Sandbox Code Playgroud)
我想用DeptId和新列boolean创建一个新表,如果同一部门的所有员工在2010年12月1日(12月1日)之前加入并且他们的薪水应该大于8000,则返回true.所以在这种情况下,结果应该是
DeptId NewEmployees
------------------------
1 False
2 True
Run Code Online (Sandbox Code Playgroud)
最好的方法是什么?我应该自己加入吗?或者还有其他方法吗?请任何人都可以提出建议......
Jeena.
我有这样的文件
1111,K1
2222,L2
3333,LT50
4444,K2
1111,LT50
5555,IA
6666,NA
1111,NA
2222,LT10
Run Code Online (Sandbox Code Playgroud)
需要的输出
1111,K1,LT50,NA
2222,L2,LT10
3333,LT50
4444,K2
5555,IA
6666,NA
Run Code Online (Sandbox Code Playgroud)
第1列列号可以随时重复,但我需要的输出是sort和uniq
我正在尝试以下列格式查找链接:
http://subdomain.subdomain.domain.tld/subfolder/randomstring.html
Run Code Online (Sandbox Code Playgroud)
基本上,我需要一个正在查找http://并在找到时停止查找的正则表达式.html.介于两者之间的一切都无所谓.即,更多/更少的子域,可变TLD和变量文件夹.
这可能吗?
((http://)?=(.html))
Run Code Online (Sandbox Code Playgroud)
我到目前为止(没有功能)是这样的.我真的不熟悉前瞻性断言,所以我可能走错了路.
无论如何,任何帮助将不胜感激!
如何在sum上创建一个函数,如sum,min,max?
它将在结果集上运行.
Select join(',', Name), sum(total) From Account Group By IdCity
Run Code Online (Sandbox Code Playgroud) 在Windows上使用cmd,使用pushd很容易为UNC路径分配驱动器号:
C:\Windows\> pushd \\server\share\path
Y:\> popd
C:\Windows\>
Run Code Online (Sandbox Code Playgroud)
但是我希望能够对本地路径执行相同操作,因为它会缩短文件路径,并且我必须使用不支持具有很长路径的文件的命令.
这个想法是G:在脚本中没有硬编码的情况,因为它可以在另一台机器上使用.
subst G: .
pushd G:\
(other commands)
popd
subst G: /d
Run Code Online (Sandbox Code Playgroud)
我试过pushd \\?\%CD%但不幸的是它不起作用......
有没有人有魔术呢?
谢谢
以下是我的代码
/* Initialise default without options input. */
options -> processHiddens = false;
options -> timeResolution = DEFAULT_MOD_TIMES;
options -> performSync = true;
options -> recursive = false;
options -> print = false;
options -> updateStatus = true;
options -> verbose = false;
options -> programname = malloc(BUFSIZ);
options -> programname = argv[0];
while ((opt = getopt(argc, argv, OPTLIST)) != -1)
{
switch (opt)
{
case 'a':
!(options -> processHiddens);
case 'm':
options -> timeResolution = atoi(optarg);
case 'n':
!(options …Run Code Online (Sandbox Code Playgroud) 首先感谢论坛在将用C++ 0x函数编写的函数转换为C++ 03时提供的支持.我还有更多的线要转换.在完成任务之前,我有一个主要的编译错误(在VS 2008中)以修复以下代码.
(错误读作"只允许在全局,名称空间或类范围内使用模板声明")
#include "stdafx.h"
#define EMPTY(x, func)
#define ACTION(x, func) func(x)
#define IFRETURN(x, func) if (!func(x)) { return; }
#define BIN_TREE_TRAVERSAL(NAME, PRE, IN, POST) \
template <typename node_t, typename func_t> \
void NAME (node_t* proot, func_t const& func) \
{ \
if (proot) \
{ \
PRE(proot, func); \
NAME(proot->left (), func); \
IN(proot, func); \
NAME(proot->right(), func); \
POST(proot, func); \
} \
}
BIN_TREE_TRAVERSAL(inorder, EMPTY, ACTION, EMPTY)
BIN_TREE_TRAVERSAL(preorder, ACTION, EMPTY, EMPTY)
BIN_TREE_TRAVERSAL(postorder, EMPTY, EMPTY, ACTION) …Run Code Online (Sandbox Code Playgroud) GDB告诉我第52行导致了分段错误.我不明白为什么.我正在实现一个简单的堆栈.它有两个功能:pop和push.看来pop不起作用.pop的目的是检索堆栈上的最高值.但是,当它试图这样做时,我得到一个分段错误.有谁知道原因?
/*************************************************************************
* stack.c
*
* Implements a simple stack structure for char* s.
************************************************************************/
// for strdup() in the testing code
#define _XOPEN_SOURCE 500
#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// the capacity of the stack
#define CAPACITY 10
//global variable used to keep track of pop and push
typedef struct
{
// storage for the elements in the stack
char* strings[CAPACITY];
// the number of elements currently in the stack
int size;
}stack;
// …Run Code Online (Sandbox Code Playgroud)