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, 一句搞定 :-)
相关阅读
Oracle not availableDynamic SQL的弱问题index请教Re: 在一个database里边,xxx-xx-xxx格式的SSN算作什么数据类型?oracle中如何查询已建立的表结构Oracle SQL*Plus 的密码是啥阿?有没有必要考一个ORACLE证?請推荐一款笔记本電腦地地道道的新手求助where to find oracle9i personal edition?安装Oracle 9i R2每次到第二张盘copy ctxhx的时候就死住了[转载] intensive I/O and odbc problemRe: ?? text file, database, ODBC & MatlaHelp with Oracle Application Serverrelation table design question.[转载] Re: how to update the data?关于数据库格式互换,求教!Help! about recover Sysdba ID& password请问, oracleformstored procedure 菜鸟一问, PLEASE HELP,在线等