由买买提看人间百态

topics

全部话题 - 话题: value1
1 2 下页 末页 (共2页)
l*****y
发帖数: 8
1
来自主题: Database版 - SQL问题求救!!
本人有简单问题求教
已通过查询获得若干个结果,现必须将这些结果insert
到另一个表,say: result(number,value1,value2)
现在问题是:
只有value1 和value2是已知道的(即前面的结果)。可是
number 是一个primary key,表示序号如1,2,3,4,5,....
请问怎么样写insert into result(number,value1,value2)..???
我的意思是有100个value1,value组成的tuple.如何得到
table result such as
number value1 value 2
1 x1 y1
2 x2 y2
.....................
100 x100 y100
我尝试用

insert into result(number,value1,value2)
(
select number,A.value1,A,value2
from A
)
但是如何累加num
e*****m
发帖数: 320
2
来自主题: Statistics版 - 请教这样的数据应该怎么分析
有这样一个问题,借贵地向大家请教一下。
有一个实验,十个Subjects,每个subject先平躺,同时用方法A和方法B测数据,每种
方法测三次,得到三个数值。
然后,subject坐起来,再同时用方法A和方法B测数据,每种方法再各测三次,得到三
个数值。
然后,subject再平躺,再测。
最后,subject再坐起来,再测。
这样就得到一组这样的数值:
METHOD A, SUPINE, SUBJECT1: value1 value2 value3
METHOD B, SUPINE, SUBJECT1: value1 value2 value3
METHOD A, Sitting, SUBJECT1: value1 value2 value3
METHOD B, Sitting, SUBJECT1: value1 value2 value3
METHOD A, SUPINE, SUBJECT2: value1 value2 value3
METHOD B, SUPINE, SUBJECT2: value1 value2 value3
等等等等。。。
现在想比较:1. METHOD ... 阅读全帖
s******t
发帖数: 2374
3
来自主题: JobHunting版 - Facebook Phone Screen
找了一个以前写的递归的
public int findLowestAncestor(Node root, int value1, int value2) {
if (root == null) return -1;

if (root.value > value1 && root.value > value2) {
findLowestAncestor(root.left, value1, value2);
}
else if (root.value < value1 && root.value < value2) {
findLowestAncestor(root.right, value1, value2);
}
else return root.value;
}
l******9
发帖数: 579
4
I need to generate a new column in a table in a sql database.
the given table is:
id1 value1 value2 value3 value4
9465 387 801 1990 20
All columns are integer. All columns are integer. value1 and value2 are
always 3 digits, value3 are year value, value4 is not more than 3 digits.
I need to generate a value by combining value1 to value4, suppose that it is
called "value_combine". The "value_combine" should be unique. For example,
given the different combinations... 阅读全帖
i*******d
发帖数: 81
5
其实就两个column的表,12 million也不算大。最后的表不小。一下update 48 个
column可能要写挺长时间。
你可以先把最后表的结构create出来,先写进去所有的unique id,create index。然
后每次update一个column。
create table t1( id int, value1 int);
create table t2( id int, value2 int);
create table t3( id int, value3 int);
insert into t1 values (2,2),(3,3);
insert into t2 values (1,1),(3,3);
insert into t3 values (1,1),(2,2);
select id into final from (select id from t1 union select id from t2 union
select id from t3) as t;
create clustered index id on final(id);
al... 阅读全帖
l******9
发帖数: 579
6
【 以下文字转载自 JobHunting 讨论区 】
发信人: light009 (light009), 信区: JobHunting
标 题: generate unique integer ID from columns in SQL table
发信站: BBS 未名空间站 (Fri Nov 14 17:36:46 2014, 美东)
I need to generate a new column in a table in a sql database.
the given table is:
id1 value1 value2 value3 value4
9465 387 801 1990 20
All columns are integer. All columns are integer. value1 and value2 are
always 3 digits, value3 are year value, value4 is not more than 3 digits.
I need to g... 阅读全帖
l******9
发帖数: 579
7
【 以下文字转载自 JobHunting 讨论区 】
发信人: light009 (light009), 信区: JobHunting
标 题: generate unique integer ID from columns in SQL table
发信站: BBS 未名空间站 (Fri Nov 14 17:36:46 2014, 美东)
I need to generate a new column in a table in a sql database.
the given table is:
id1 value1 value2 value3 value4
9465 387 801 1990 20
All columns are integer. All columns are integer. value1 and value2 are
always 3 digits, value3 are year value, value4 is not more than 3 digits.
I need to g... 阅读全帖
a*****n
发帖数: 230
8
I have been waiting for this for 10 years. But this noon, I saw this line:
The byte code compiler and interpreter now include new instructions that
allow many scalar subsetting and assignment and scalar arithmetic operations
to be handled more efficiently. This can result in significant performance
improvements in scalar numerical code.
I immediately downloaded the latest R build and benchmark against a KD-tree
code I wrote.
R Build from 20 days ago: 8.45 minutes
R build of today: 5.01 minutes
A... 阅读全帖
n**e
发帖数: 116
9
Here is my implementation in C++. Just my two cents.
// -------------------------------------------------------------------------
---
// Name: lowestCommonAncestor
// Description: Given two values representing two node's values in a
binary
// search tree, find the lowest common ancestor of the two nodes.
//
// Assumption: We assume those two values are different and both exist in
the
// tree if the tree is not empty.
//
// Node: This algorithm returns root node if one of ... 阅读全帖
s*****g
发帖数: 17
10
来自主题: Database版 - SQL问题求救!!
In the result table, you may need an identity.
CREATE TABLE RESULT
(id int identity(1,1) not null,
value1 datatype,
value2 datatype
)
Then you can insert the values of value1 and value21.
INSERT INTO RESULT(value1, value2)
SELECT value1,value2
FROM A
Hope that it works.
i*******d
发帖数: 81
11
CTE + 一串 left outer join 可以实现。
SQL Server 三个table:
create table t1( id int, value1 int);
create table t2( id int, value2 int);
create table t3( id int, value3 int);
insert into t1 values (2,2),(3,3);
insert into t2 values (1,1),(3,3);
insert into t3 values (1,1),(2,2);
with idtable as
(select id from (select id from t1 union select id from t2 union
select id from t3) as t)
select idtable.id,isnull(value1,-1) as value1, isnull(value2,-1) as value2,
isnull(value3,-1) as value3
from idtable left ou... 阅读全帖
c*****y
发帖数: 90
12
【 以下文字转载自 DotNet 讨论区 】
发信人: cctvboy (盼好运), 信区: DotNet
标 题: 请问C#中如何update hashtable中的value?
发信站: BBS 未名空间站 (Thu Jan 14 02:56:37 2010, 美东)
比如:
Hashtable myHashTable = new Hashtable();
myHashTable.Add(key1, value1);
如何将value1增加一。这样可以吗?
hashtable[key1] = value1+1
或者直接
++hashtable[key1]?
谢谢。
m********c
发帖数: 105
13
来自主题: JobHunting版 - google scramble string O(n) 解法
贴一个我的recursive代码,time complexity是O(n^2),large Judge用了144ms,不
是最优解,但是容易理解
bool isScramble(string s1, string s2) {
// Start typing your C/C++ solution below
// DO NOT write int main() function

if (s1 == s2)
return true;

int size = s1.size();

int value1=0, value2=0;
for (int i=0; i value1 += (s1[i]-'a');
value2 += (s2[i]-'a');
}
if (value1 != value2)
r... 阅读全帖
l******9
发帖数: 579
14
I need to so a sql query on IBM netezza sql database from Aginity workbench
on win7.
My query:
SELECT *
from table1 AS c ,
table2 AS b
where CAST(c.id as int) = b.id
in table1, id is character varying(20) and in table2, id is int.
Table1:
id value1 value2
'985' 'casdqwdc' '654.3184' // they are all char
Table2:
id value1
985 694381 // id is int, value1 is int
I got error:
ERROR [HY000] ERROR: pg_atoi: error in "id": can't parse "id"
Any help would be apprec... 阅读全帖
z********4
发帖数: 1668
15
有48张表,每个表有一个id字段(建立了unique idex),一个value字段:
表1的字段:id, value1
表2的字段:id, value2
表3的字段,id, value3
……
表48的字段:id, value48
现在希望把这48张表根据id字段合并为一张,结构为:
id, value1, value2, value3,...,value48
问题是,每个表记录的id并不完全一样,表1中有的id表2中可能没有,反之亦然。但是
要求保留所有在48张表中出现过的id。如果这个id在表x中不存在,那么合并后的总表
中,这个id的valuex字段赋一个-1值。
例如,总表可能是这样的:
id, value1, value2, value3,...,value48
a, 1, 2, 3, ..., -1
b, 2, -1, 3, .... 3
...
另外一个问题是,每个表都非常大,记录数量在1200w左右。
数据库为postgresql,求好的解决方案。感谢!
l******9
发帖数: 579
16
【 以下文字转载自 JobHunting 讨论区 】
发信人: light009 (light009), 信区: JobHunting
标 题: Error of SQL query on IBM netezza SQL database from Aginity workbench
发信站: BBS 未名空间站 (Fri Dec 5 16:46:56 2014, 美东)
I need to so a sql query on IBM netezza sql database from Aginity workbench
on win7.
My query:
SELECT *
from table1 AS c ,
table2 AS b
where CAST(c.id as int) = b.id
in table1, id is character varying(20) and in table2, id is int.
Table1:
id value1 value2
'985' 'casdqwdc' '654.3184' // t... 阅读全帖
c*****y
发帖数: 90
17
比如:
Hashtable myHashTable = new Hashtable();
myHashTable.Add(key1, value1);
如何将value1增加一。这样可以吗?
hashtable[key1] = value1+1
或者直接
++hashtable[key1]?
谢谢。
h*z
发帖数: 34
18
来自主题: Programming版 - C++ 两个project enum value名冲突
具体情况看下面的code,project2要用到project1的API,但是project2中header2.h文件
的一个enum Type2的value与project1中header1.h文件的enum Type1的value相同出现
冲突. project1和project2都是很大的项目, 有legacy的原因, 所以直接改value不是
很方便. 不知道板上的大侠有没有碰到类似情况, 该如何处理.
//Project 1:
//header1.h
enum Type1
{
VALUE0=0,
VALUE1,
VALUE2,
VALUE3
};
///////////////////////////////////
//Project 2:
//header2.h
enum Type2
{
VALUE0=0,
VALUE1,
VALUE2
};
///////////
//Main.cpp in Project 2
#include "header1.h"
#in... 阅读全帖
l******9
发帖数: 579
19
【 以下文字转载自 JobHunting 讨论区 】
发信人: light009 (light009), 信区: JobHunting
标 题: Error of SQL query on IBM netezza SQL database from Aginity workbench
发信站: BBS 未名空间站 (Fri Dec 5 16:46:56 2014, 美东)
I need to so a sql query on IBM netezza sql database from Aginity workbench
on win7.
My query:
SELECT *
from table1 AS c ,
table2 AS b
where CAST(c.id as int) = b.id
in table1, id is character varying(20) and in table2, id is int.
Table1:
id value1 value2
'985' 'casdqwdc' '654.3184' // t... 阅读全帖
r********e
发帖数: 1686
20
RT
if I have a dataset as below:
id week value1
a 1 12
a 2 22
a 3 33
a 4 .
a 5 .
a 6 .
a 7 .
b 1 78
b 2 .
b 3 .
b 4 .
b 5 .
b 6 .
b 7 .
b 8 .
c 1 88
c 2 67
c 3 76
c 4 .
c 5 .
c 6 .
I need to capture the last missing value1 for each ID as value2 to achieve
the following dataset:
id week value1 value2
a 1 12 33
a 2 22 33
a 3 33 33
a... 阅读全帖
k*******a
发帖数: 772
21
写了一个,不过有点繁
data a;
input id $ week value1;
datalines;
a 1 12
a 2 22
a 3 33
a 4 .
a 5 .
a 6 .
a 7 .
b 1 78
b 2 .
b 3 .
b 4 .
b 5 .
b 6 .
b 7 .
b 8 .
c 1 88
c 2 67
c 3 76
c 4 .
c 5 .
c 6 .
;
data b;
set a;
by id;
if value1 ne . then do
value2=value1;
retain value2;
end;
if last.id then output;
keep id value2;
data a;
merge a b;
by id;
proc print data=a;run;
R*********i
发帖数: 7643
22
It souds like a typical LOCF question:
proc sort data=a;
by id week;
data locf;
set a;
by id week;
where value1>.;
if last.id;
data out;
merge a locf (keep=id value1 rename=(value1=value2));
by id ;
proc print;
run;
c**********e
发帖数: 2007
23
【 以下文字转载自 Programming 讨论区 】
发信人: careerchange (Stupid), 信区: Programming
标 题: How to convert string to string array (or vector)
发信站: BBS 未名空间站 (Mon Sep 13 19:18:21 2010, 美东)
It looks that`in Java, there is a function Split which convert a string to a
string array. I wonder if we could do the same in C++. How to do the
conversion?
string MyString = "value1;value2;value3;value4;"
string[] MyStringArray = MyString.Split(';');
MyStringArray[0] (would give value1)
MyStringArray[1] (would give value2)
g***s
发帖数: 3811
24
来自主题: JobHunting版 - 求解比硬币找零稍难的一题
Since the DP stores all the values, we don't need to handle (log v_N) times.
So, it is same time complexity of Knapsack problem.
new_V < 2*V
Knapsack can be handle in O(N*V), so this question can be handled in O(N*2*V
) = O(N*V). N is the type of coins.
the O(N*V) codes for knapsack are hard to read. following is sample codes,
time = O(V * sigma log s_i) .
public static int getMinStampNum(Coin[] coins, int V) {
ArrayList p = new ArrayList();
for (Coin coin ... 阅读全帖
l******9
发帖数: 579
25
【 以下文字转载自 Database 讨论区 】
发信人: light009 (light009), 信区: Database
标 题: keep group of values of SQL procedure in one table
发信站: BBS 未名空间站 (Sat May 24 09:48:08 2014, 美东)
I need to print out a group of values from a procedure on SQL server 2008.
If I use select , it generated a distinct table into the result part of SQL
server 2008 managemetn studio every time the procedure is called.
i need to call the procedure in a loop. I want to print the values into one
table.
Thx!
while
begin
my_proce... 阅读全帖
M*****t
发帖数: 26706
26
来自主题: LosAngeles版 - mysql的问题
要连接两个表,Key用来联接的。这两个表里,都有一些key missing,所以我想连接后
的数据显示null value from both tables. 谁知道怎么弄?
表一
Key Value1
A 1
B 2
C 2
D 2
表二
Key Value2
A 3
B 2
F 2
连接后的表:
Key Value1 Value2
A 1 3
B 2 2
C 2 null
D 2 null
F null 2
p****s
发帖数: 3184
27
来自主题: Database版 - SQL问题求救!!

In Oracle, it is quite easy to achieve this by using SEQUENCE.
E.g.,
CREATE SEQUENCE my_sequence
INCREMENT BY 1
START WITH 1
NOMAXVALUE;
INSERT INTO result(number,value1,value2)
select my_sequence.nextval, A.value1,A,value2
from a;
DROP SEQUENCE my_sequence.
In DB2, you must use user-defined function with scratchpad (check
Chamberline's book for coding examples) to achieve the same effects.
c*****d
发帖数: 6045
28
来自主题: Database版 - mysql index优化求助 (转载)
我没太看懂
你这个试验怎么做的?
a table with 300+M rows
count(*) costs 2 seconds?
另外你count where on no index take 12 seconds
是select count(index_col) where col = value1
还是select index_col where col = value1?
l******9
发帖数: 579
29
I need to print out a group of values from a procedure on SQL server 2008.
If I use select , it generated a distinct table into the result part of SQL
server 2008 managemetn studio every time the procedure is called.
i need to call the procedure in a loop. I want to print the values into one
table.
Thx!
while
begin
my_procedure()
end
my_procedure()
# do something
select value1, value2, value3
i need to keep the
value1, value2, value3
in one single table after the loop is don... 阅读全帖
h****b
发帖数: 157
30
来自主题: Programming版 - 问个c++问题
Is there anything wrong with this C++ class declaration?
class temp
{
int value1;
mutable int value2;
public :
void fun(int val)
const{
((temp*) this)->value1 = 10;
value2 = 10;
}
};
为什么我编译没问题? 再有((temp*) this)什么意思? const函数不是不能改变
member
variable?
多谢
s*******e
发帖数: 664
31
来自主题: Programming版 - [合集] c++ parameter reflection
☆─────────────────────────────────────☆
igah (igah) 于 (Mon Sep 21 21:38:57 2009, 美东) 提到:
here is the problem i am facing a lot when writing many applications in c++.
let's say you have a user class Foo and you need some parameters, e.g.
struct Foo {
int value1;
double value2;
};
and the parameters are read from some property file of name-value pairs:
value1=123
value2=23.4
the parameters can be changed at run time through some user interface (e.g.
jmx like controls) which sets the values al
c**********e
发帖数: 2007
32
It looks that`in Java, there is a function Split which convert a string to a
string array. I wonder if we could do the same in C++. How to do the
conversion?
string MyString = "value1;value2;value3;value4;"
string[] MyStringArray = MyString.Split(';');
MyStringArray[0] (would give value1)
MyStringArray[1] (would give value2)
etc......
s****n
发帖数: 700
33
来自主题: Programming版 - python数据处理的一个问题
我有数据格式如下,
date time product value1 value2 value3
..
..
..
..
there are 10 different type of product. we call it P1, P2, P3, P4,....P10
I want to calculate Min/Max, mean, std of value1/2/3 for given product
in a range of datetime.
so my input is,
dataset, $product, $begin_datetime, $end_datetime
output is,
min/max, mean, std
Thanks for your help!
l******9
发帖数: 579
34
【 以下文字转载自 Database 讨论区 】
发信人: light009 (light009), 信区: Database
标 题: keep group of values of SQL procedure in one table
发信站: BBS 未名空间站 (Sat May 24 09:48:08 2014, 美东)
I need to print out a group of values from a procedure on SQL server 2008.
If I use select , it generated a distinct table into the result part of SQL
server 2008 managemetn studio every time the procedure is called.
i need to call the procedure in a loop. I want to print the values into one
table.
Thx!
while
begin
my_proce... 阅读全帖
t********1
发帖数: 799
35
来自主题: Statistics版 - SAS quarter calculation question
there is a table with different variables as below,
yyyymmm, value1(%), value2(%), value3(%), .......
now I need to calculate every three observations' accummulated percent, i.e.
quarterly accummulated percent for value1,value2, value3,.....
How can I realize this? Thank you very much.
H*******r
发帖数: 98
36
来自主题: Statistics版 - 编程菜鸟问一个sas编程问题
one is...
data select;
set original;
where var1 in (value1 value2 value3 value4 value5 value6 value7 value8)
or
var1 between minvalue and maxvalue or
var2 in (number1 number2 number3) or
var3 in (number1 number2 number3) or
var4 in (number1 number2 number3) or
var5 in (number1 number2 number3) or
var6 in (number1 number2 number3) or
var7 in (number1 number2 number3) or
var8 in (number1 number2 number3) or
... 阅读全帖
l******9
发帖数: 579
37
【 以下文字转载自 Database 讨论区 】
发信人: light009 (light009), 信区: Database
标 题: keep group of values of SQL procedure in one table
发信站: BBS 未名空间站 (Sat May 24 09:48:08 2014, 美东)
I need to print out a group of values from a procedure on SQL server 2008.
If I use select , it generated a distinct table into the result part of SQL
server 2008 managemetn studio every time the procedure is called.
i need to call the procedure in a loop. I want to print the values into one
table.
Thx!
while
begin
my_proce... 阅读全帖
s*********h
发帖数: 6288
38
来自主题: DataSciences版 - Spark group问题
如果我想把(key,value1) (key,value2),....(key,valueN)这样的group成
(key,[value1,value2,value3...valueN])
而不使用groupByKey,应该怎么实现啊?
另一方面用了groupByKey出现的是
(key, )
第二个东西不是一个list
s****n
发帖数: 700
39
来自主题: DataSciences版 - python数据处理的一个问题 (转载)
【 以下文字转载自 Programming 讨论区 】
发信人: sallen (keep looking), 信区: Programming
标 题: python数据处理的一个问题
发信站: BBS 未名空间站 (Mon Feb 1 21:08:36 2016, 美东)
我有数据格式如下,
date time product value1 value2 value3
..
..
..
..
there are 10 different type of product. we call it P1, P2, P3, P4,....P10
I want to calculate Min/Max, mean, std of value1/2/3 for given product
in a range of datetime.
so my input is,
dataset, $product, $begin_datetime, $end_datetime
output is,
min/max, mean, std
Thanks for your h... 阅读全帖
s****n
发帖数: 700
40
来自主题: DataSciences版 - python数据处理的一个问题 (转载)
【 以下文字转载自 Programming 讨论区 】
发信人: sallen (keep looking), 信区: Programming
标 题: python数据处理的一个问题
发信站: BBS 未名空间站 (Mon Feb 1 21:08:36 2016, 美东)
我有数据格式如下,
date time product value1 value2 value3
..
..
..
..
there are 10 different type of product. we call it P1, P2, P3, P4,....P10
I want to calculate Min/Max, mean, std of value1/2/3 for given product
in a range of datetime.
so my input is,
dataset, $product, $begin_datetime, $end_datetime
output is,
min/max, mean, std
Thanks for your h... 阅读全帖
q*********u
发帖数: 280
41
hash恐怕那些整数不适合当key, 如果是后面名字当key的话,没办法做value1+value2=
sum了,其实这个题复习了,可惜就是没事先写出来,写出来就能抄了。

好像跟范围也没太大关系吧?
或者空间没限制,直接用hash,不用sort
n***k
发帖数: 2780
42
what's the best data structure for storing and looking up a huge amount of
url's (presented in a prefix format) like these:
com.google.www -> value1
com.yahoo.finance -> value2
com.yahoo.finance/stocks -> value3
com.yahoo/finance -> value2
1.2.3.4/node/123 -> value4
....
the requirements are:
1. it has to be compact (compression if necessary).
2. lookup time should be fast (constant would be ideal, but a few level of
tree lookup is fine too).
z**********8
发帖数: 229
43
来自主题: JobHunting版 - 汉若塔问题
#include
using namespace std;
#include
#include
class Tower{
private:
int index;//indicate the number of tower
stack one_tower;
public:
Tower(int i=0):index(i){}//constructor
int getindex();
void add(int d);
void moveTopTo(Tower t);
void print();
void moveDisks(int n,Tower Destination,Tower buffer);
};
int Tower::getindex()
{
return index;
}
void Tower::add(int d)
{
if((!one_tower.empty())&&(d>one_tower.top()))
cout<<"... 阅读全帖
b*******d
发帖数: 750
44
来自主题: JobHunting版 - 面经
最近面了几个公司,大的如LG,中等的PDB,小的有20~30个人的三个,tiny的7,8个
人的两三个,人不错,但太risky。
最想去的没有中, 水平问题。从一个,凑活300K过日子。
拿到卡后的骑驴找马。太累,收山,生娃。
1. numPath from top left to bottom right.
写没想到这个居然栽了,被对方态度搞的不能focus,写出来但总出错。水平问题。
2. find median in 2 sorted arrays
3. find median in very large file of LONGs in many machines.
global value space binary search; bucket stats; reduce number of passes of
files.
4. implement web crawler in java
不是project,就是 task queue, executor。
5. implement Timer, Timer Task in java
prirotity queue; num... 阅读全帖
l*********r
发帖数: 122
45
来自主题: JobHunting版 - 一道面试题请教
每条记录格式为
记录数目增长很快.
要求的运算是计算每分钟各个value的均值
假定有一个cloud provider如AWS,
解释 用什么样的 technologies去存data 和运算.
m*********y
发帖数: 10616
46
正确的数据。
Share Structure
Market Value1 $24,122,618 a/o ?? 28, 2010
Shares Outstanding 1,813,730,683 a/o ?? 12, 2010
Float 1,404,099,438 a/o ?? 12, 2010
Authorized Shares 2,000,000,000 a/o ?? 12, 2010
Par Value 0.0100
q**1
发帖数: 193
47
来自主题: BuildingWeb版 - PHP问题
如何调用其它 html 或 php file,并传递参数。我现在用

contain 其他网页,但是不知道如何将当前文件里定义的参数
传递到 component.html
我原先用 Perl 的 HTML::Mason 可以
<& /path/to/component.html, arg1 => value1, arg2 => value2 &>
然后在 component.html里面做相应设置。。
请问,在 PHP 里面如何实现?? //bow
1 2 下页 末页 (共2页)