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, 一句搞定 :-)
相关阅读
新手请教ACCESS的SUM功能oracle dbca help?long and CLOB.. any differences? 数据库应用程序服务器端的发布问题。Help!!!! How to synchronized the data in SQL serveroracle questionHow to start PostgreSQL service?How to dump tables from Oracle to Access?[转载] Re: date conversion[转载] Database Interface in ANSI C++?Do you thing the thread view is good or the chronical view is good?ODBC call wont return output parameter and no err请教一个sql server的问题[转载] RPDT Status Updateanybody got oracle 9i certificate? 急disable constraint日期格式初级问题install mysqlHelp needed in SQL[Help]怎么改Access数据库所在的文件夹权限?