j*n
2 楼
well, it is 43$ value...
http://safari.oreilly.com/1565927567/transqlcook-CHP-3-SECT-16
this is a calculation of a squared matrix trace or sum of its n eigenvalues.
just tell the interviewer go to hell, SQL query is not dedicated to do such
mathematic calculation. there is tons of statistical analysis software can
easily resolve this problem, even you can use C++ do handle it.
at least I am not stupid enough to consider using SQL.
http://safari.oreilly.com/1565927567/transqlcook-CHP-3-SECT-16
this is a calculation of a squared matrix trace or sum of its n eigenvalues.
just tell the interviewer go to hell, SQL query is not dedicated to do such
mathematic calculation. there is tons of statistical analysis software can
easily resolve this problem, even you can use C++ do handle it.
at least I am not stupid enough to consider using SQL.
j*n
3 楼
2nd thought...
this might be using SQL inside SAS.
you may transform this nxn matrix into a data set with 2 columns:
one is a list of all numeric data, another one is the location flag of each
number.
you may flag out each of diagonal data as 'Y', then now you can do it with
simple SELECT with sum().
this might be using SQL inside SAS.
you may transform this nxn matrix into a data set with 2 columns:
one is a list of all numeric data, another one is the location flag of each
number.
you may flag out each of diagonal data as 'Y', then now you can do it with
simple SELECT with sum().
B*g
4 楼
其实我真的很无聊,搞了一个user defined function in oracle.
CREATE OR REPLACE FUNCTION CalculateDiagonal(pivTableName IN VARCHAR2)
RETURN NUMBER IS
TYPE ltypColumn IS TABLE OF user_tab_cols%ROWTYPE;
lrecColumn ltypColumn;
TYPE ltypSeqNo IS TABLE OF VARCHAR2(100);
lrecSeqNo ltypSeqNo;
lnTotal NUMBER := 0;
lnTmpTotal NUMBER := 0;
lvSql VARCHAR (1000) := '';
BEGIN
lvSql := 'SELECT * FROM user_tab_cols WHERE table_name = ''' ||
pivTableName || '''';
EXECUTE IMME
【在 s****l 的大作中提到】
: 请教一个求职面试题:如何写一个SQL query求表中对角线的和
CREATE OR REPLACE FUNCTION CalculateDiagonal(pivTableName IN VARCHAR2)
RETURN NUMBER IS
TYPE ltypColumn IS TABLE OF user_tab_cols%ROWTYPE;
lrecColumn ltypColumn;
TYPE ltypSeqNo IS TABLE OF VARCHAR2(100);
lrecSeqNo ltypSeqNo;
lnTotal NUMBER := 0;
lnTmpTotal NUMBER := 0;
lvSql VARCHAR (1000) := '';
BEGIN
lvSql := 'SELECT * FROM user_tab_cols WHERE table_name = ''' ||
pivTableName || '''';
EXECUTE IMME
【在 s****l 的大作中提到】
: 请教一个求职面试题:如何写一个SQL query求表中对角线的和
M*r
5 楼
我估计哈,原意是想要一个非常fancy/tricky的SQL Query, 一句搞定 :-)
【在 B*****g 的大作中提到】
: 其实我真的很无聊,搞了一个user defined function in oracle.
: CREATE OR REPLACE FUNCTION CalculateDiagonal(pivTableName IN VARCHAR2)
: RETURN NUMBER IS
: TYPE ltypColumn IS TABLE OF user_tab_cols%ROWTYPE;
: lrecColumn ltypColumn;
:
: TYPE ltypSeqNo IS TABLE OF VARCHAR2(100);
: lrecSeqNo ltypSeqNo;
: lnTotal NUMBER := 0;
: lnTmpTotal NUMBER := 0;
【在 B*****g 的大作中提到】
: 其实我真的很无聊,搞了一个user defined function in oracle.
: CREATE OR REPLACE FUNCTION CalculateDiagonal(pivTableName IN VARCHAR2)
: RETURN NUMBER IS
: TYPE ltypColumn IS TABLE OF user_tab_cols%ROWTYPE;
: lrecColumn ltypColumn;
:
: TYPE ltypSeqNo IS TABLE OF VARCHAR2(100);
: lrecSeqNo ltypSeqNo;
: lnTotal NUMBER := 0;
: lnTmpTotal NUMBER := 0;
B*g
6 楼
hehe, I guess there is no such sql.
sql server solution:
http://topic.csdn.net/u/20080426/01/16e239df-0977-4bdf-9680-1bd1690b98fe.html
【在 M*****r 的大作中提到】
: 我估计哈,原意是想要一个非常fancy/tricky的SQL Query, 一句搞定 :-)
sql server solution:
http://topic.csdn.net/u/20080426/01/16e239df-0977-4bdf-9680-1bd1690b98fe.html
【在 M*****r 的大作中提到】
: 我估计哈,原意是想要一个非常fancy/tricky的SQL Query, 一句搞定 :-)
相关阅读
can i ...?HELP! need info on QBE(Query By Example)请问有谁知道关于PGP和SSL的中文站点及好的国外站点怎样在T-SQl中执行一条放在varchar中的命令a question of ODBC, thanks有对中间件熟的么?Re: [转载] somebody posted the junkdummy question~{Gk=L~} CS expert !!!is oracle the best database pro?primary key?Data Mining and OLAPhelp with a simple query那位大虾告诉我?怎样从WEB上执行调用DTS TASK?Question?IBM Overtakes Oracle In Database Race数据库研究要求什么?[转载] Oracle Database Administrator (DBA) and Developeroralce8 and UTF8 support