AKB Forums

Go Back   AKB Forums > Technical sections > Algorithms
Home Register Blogs FAQ Members List Calendar Downloads Arcade Mark Forums Read

Algorithms The source of algorithms for your project

Troubles when posting message? Click here! :: Проблемы с отправлением сообщения? Нажмите сюда!

Reply
 
LinkBack Thread Tools Display Modes
Old Jul 21, 2005, 17:54   #1
Silence
 
Moonlight's Avatar
 
Join Date: Nov 2004
Location: back to meta level
Posts: 3,862
Blog Entries: 3
Rep Power: 4
Reputation: 144
Send a message via Skype™ to Moonlight
sql task. sos plz!

Description of the application. The following relational schema is used to maintain stock
price information.
stocks (skey, issued)

For each stock in the database, a unique identifier (skey, data type varchar2(10)) and
the date the stock was issued (issued, data type date) is stored.

stockdev (skey, tdate, price)

This table stores the time series of the diferent stock prices. For each stock referenced
by skey and trading day (tdate, data type date) the price (price, data type number)
is stored.

Compute the covariance of the time series of the stocks 'oracle' and 'ibm'.
Hint: In order to compute the covariance of two random variables you may use the
formula cov(X; Y ) = E(X  Y )
---------------------------
i got some ideas, but noth comes out

SELECT (SUM ( x * y ) - SUM ( y ) * SUM ( x ) * SUM ( x ) / n) / n

FROM stockdev
where ....?

but duno how to tell, that x is skey "oracle'-s price & y - ibm's. price1, price2??

was hinted to put subqueries into the cov formula:

SELECT (SUM (select price from stockdev where skey='oracle' AND tdate BETWEEN issuedate AND ??

or group by tdate?

how to tell that it's time series & not 1
can one say MAX(date) meaning the last date?
no, you should sort in order to get last date
Silence (07:37 PM) :
nasty.. group by won't do?\
__________________
Nothing is eternal under the Moon…

Miacum.ru
Moonlight is offline   Reply With Quote Quote selected
Old Jul 21, 2005, 18:00   #2
Silence
 
Moonlight's Avatar
 
Join Date: Nov 2004
Location: back to meta level
Posts: 3,862
Blog Entries: 3
Rep Power: 4
Reputation: 144
Send a message via Skype™ to Moonlight
it's not even readable. task is here: http://iwi.wiwi.hu-berlin.de/downloa..._2003s_KL2.pdf

2. (d)

table stockdev should be created smth like this:

CREATE table stockdev (
skey varchar2 (10), NOT NULL,
tdate date 'dd.mm.yyyy', NOT NULL,
price number(6,2)
);
__________________
Nothing is eternal under the Moon…

Miacum.ru
Moonlight is offline   Reply With Quote Quote selected
Old Jul 21, 2005, 18:33   #3
Silence
 
Moonlight's Avatar
 
Join Date: Nov 2004
Location: back to meta level
Posts: 3,862
Blog Entries: 3
Rep Power: 4
Reputation: 144
Send a message via Skype™ to Moonlight
chto-t rodila

SELECT (SUM ( ibm.price * oracle.price ) - SUM ( oracle.price ) * SUM ( ibm.price ) * SUM ( ibm.price ) / n) / n
FROM stockdev
where ibm.skey='ibm' AND oracle.skey='oracle'
......... ;

mi xoskov ostaetca serialize it. sdelat' eto s issue date do current date. examen zavtra utrom, do etogo any help is appreciated
__________________
Nothing is eternal under the Moon…

Miacum.ru
Moonlight is offline   Reply With Quote Quote selected
Old Jul 21, 2005, 19:32   #4
ЙЦУКЕН
 
Join Date: Jul 2002
Location: 0x68,0x69,0x72, 0x69,0x6e,0x67, 0x20,0x6e,0x6f, 0x77
Posts: 3,111
Rep Power: 6
Reputation: 10
Send a message via ICQ to nm
какой sql сервер?
nm is offline   Reply With Quote Quote selected
Old Jul 21, 2005, 19:40   #5
Silence
 
Moonlight's Avatar
 
Join Date: Nov 2004
Location: back to meta level
Posts: 3,862
Blog Entries: 3
Rep Power: 4
Reputation: 144
Send a message via Skype™ to Moonlight
libo oracle libo mysql. ne vajno, doljni pisat' na bumajke ya privikla po oracle.
viju pm, thx, sha postuchus'
__________________
Nothing is eternal under the Moon…

Miacum.ru
Moonlight is offline   Reply With Quote Quote selected
Old Jul 21, 2005, 20:38   #6
Младенец
 
Karinchik's Avatar
 
Join Date: Jul 2005
Location: Massachusetts
Posts: 1
Rep Power: 0
Reputation: 10
Send a message via ICQ to Karinchik Send a message via MSN to Karinchik Send a message via Yahoo to Karinchik
a) the table creation is corect dont' forget to crate constrain on stockdev where skey is a foreign key on stocks
b) Select AVG(stockdev.price) from stockdev, stocks where stockdev.skey = stocks.skey and stocks.issued < '01/01/2003' on the date you might have to put the to_date format but it should work without date format as well
c) Update stockdev set stockdev.price = 0.11 where stockdev.tdate like (select Max(stocks.issued) from stocks where stocks.skey = 'sun')

esli ya voprosi konechno pravil'no ponyala. Naschet d) u menya chego to mozgi gluchat i ne mogu ponyat' chto imenno trebuetsya. item c) mojno po raznomu napisat', but this is one of the options.

Item d) es k mtatsem, vor helks glhis ga k patashanem
Karinchik is offline   Reply With Quote Quote selected
Old Jul 21, 2005, 20:44   #7
ЙЦУКЕН
 
Join Date: Jul 2002
Location: 0x68,0x69,0x72, 0x69,0x6e,0x67, 0x20,0x6e,0x6f, 0x77
Posts: 3,111
Rep Power: 6
Reputation: 10
Send a message via ICQ to nm
Quote:
Originally Posted by Karinchik
.......
c)
UPDATE stockdev
SET stockdev.price = 0.11
WHERE stockdev.tdate LIKE (
SELECT MAX(stocks.issued) FROM stocks WHERE stocks.skey = 'sun'
)
...............

не, не правильно
nm is offline   Reply With Quote Quote selected
Old Jul 21, 2005, 21:10   #8
Silence
 
Moonlight's Avatar
 
Join Date: Nov 2004
Location: back to meta level
Posts: 3,862
Blog Entries: 3
Rep Power: 4
Reputation: 144
Send a message via Skype™ to Moonlight
Karinchik, thx for help! for a) nm had already reminded me of pk & fk-s, it's fixed
Quote:
Originally Posted by Karinchik
c) Update stockdev set stockdev.price = 0.11 where stockdev.tdate like (select Max(stocks.issued) from stocks where stocks.skey = 'sun')
i wrote it so:

INSERT INTO stockdev values ('sun', stocks.issued, '0.01');

but i'm not sure on value for date. uchitel' nm, podskajite?:P

a d toje uje reshili, k moemu last trial nado bilo dobavit' where cond, that dates r =. nm, esho raz senks viydet tak:
SELECT (SUM ( ibm.price * oracle.price ) - SUM ( oracle.price ) * SUM ( ibm.price ) * SUM ( ibm.price ) / COUNT(tdate)) / COUNT(tdate)
FROM stockdev ibm, stockdev oracle
where ibm.skey='ibm' AND oracle.skey='oracle' AND ibm.tdate=oracle.tdate;

ili esho ludshe:
SELECT ( avg( ibm.price * o.price)-( avg(ibm.price) * avg(o.price) ) )
FROM stockdev ibm, stockdev o
WHERE ibm.skey='ibm' AND o.skey='oracle' AND ibm.tdate=o.tdate;
__________________
Nothing is eternal under the Moon…

Miacum.ru
Moonlight is offline   Reply With Quote Quote selected
Old Jul 21, 2005, 21:40   #9
Профессор
 
Nikita's Avatar
 
Join Date: Jan 2005
Location: Perm
Posts: 2,142
Rep Power: 4
Reputation: 10
Send a message via ICQ to Nikita
Ты теперь художник/поэт или SQL-ом занимешся ?
Nikita is offline   Reply With Quote Quote selected
Old Jul 21, 2005, 21:48   #10
Silence
 
Moonlight's Avatar
 
Join Date: Nov 2004
Location: back to meta level
Posts: 3,862
Blog Entries: 3
Rep Power: 4
Reputation: 144
Send a message via Skype™ to Moonlight
kajetca ya nepravil'no ponela task c), trebuet ne dobavlyat' esho 1 tuple into table, a update uje sushestvuyushiy. u Karinchik bolee blizko, poprobuyu escho:

UPDATE stockdev
set price = 0.11
where skey = 'sun' AND tdate=issued;

no issued tut iz drugovo tablea, so doljni select data from both tables.. stocks.issued itd, no u menya uje boshka bum bum, utro vechera mudrenee vsem pasibki i spoki nochi
__________________
Nothing is eternal under the Moon…

Miacum.ru
Moonlight is offline   Reply With Quote Quote selected
Old Jul 21, 2005, 21:52   #11
Silence
 
Moonlight's Avatar
 
Join Date: Nov 2004
Location: back to meta level
Posts: 3,862
Blog Entries: 3
Rep Power: 4
Reputation: 144
Send a message via Skype™ to Moonlight
Quote:
Originally Posted by accemic26
Ты теперь художник/поэт или SQL-ом занимешся ?
ya teper' studentka, u kogo 4 majora, vibiray po svoemu vkusu a mojet ludshe zadachi poreshish? u menya ix esho mnogo.. php geeks r also welcome
__________________
Nothing is eternal under the Moon…

Miacum.ru
Moonlight is offline   Reply With Quote Quote selected
Old Jul 22, 2005, 06:49   #12
Профессор
 
Nikita's Avatar
 
Join Date: Jan 2005
Location: Perm
Posts: 2,142
Rep Power: 4
Reputation: 10
Send a message via ICQ to Nikita
что есть студентка у которой 4-е мажера ?
Nikita is offline   Reply With Quote Quote selected
Old Jul 22, 2005, 07:42   #13
Профессор
 
Nikita's Avatar
 
Join Date: Jan 2005
Location: Perm
Posts: 2,142
Rep Power: 4
Reputation: 10
Send a message via ICQ to Nikita
пиши на мэйл ... может помогу . Тут не буду.
Nikita is offline   Reply With Quote Quote selected
Old Jul 22, 2005, 07:51   #14
Silence
 
Moonlight's Avatar
 
Join Date: Nov 2004
Location: back to meta level
Posts: 3,862
Blog Entries: 3
Rep Power: 4
Reputation: 144
Send a message via Skype™ to Moonlight
vremeni na mails netu, ex exams r here, we train on them
http://iwi.wiwi.hu-berlin.de/(lpzab5...x?id=2&m_id=25

course db management, esli smojesh pomoch s paru php tasks from SS 2002, stuchis' v pm, skinu asku
__________________
Nothing is eternal under the Moon…

Miacum.ru
Moonlight is offline   Reply With Quote Quote selected
Old Jul 22, 2005, 13:39   #15
панаехавший
 
Obelix's Avatar
 
Join Date: Jun 2003
Location: форпост
Posts: 4,001
Rep Power: 5
Reputation: 10
Send a message via ICQ to Obelix
кудай пхп, посмотрим )
__________________
Իսկ ԴՈՒ արդեն վաճառե՞լ ես Հայրենիքդ ռուսներին:

My Exchange Rate Monitor | Իմ Արտարժույթի Մոնիտորը

Obelix is offline   Reply With Quote Quote selected
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MS SQL RAM problem armen13 Languages, Compilers and Interpreters 6 Jan 12, 2005 10:19
Sql Collation Problem Masud Languages, Compilers and Interpreters 13 Mar 21, 2004 05:08
SQL first steps shatver Languages, Compilers and Interpreters 13 Nov 13, 2002 18:35
sql Paloma Languages, Compilers and Interpreters 9 Oct 20, 2002 13:32
Mojno li v VB kod vstavit sql zapros serty Languages, Compilers and Interpreters 1 Jul 18, 2002 10:41


All times are GMT. The time now is 21:37.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
This board was founded on September 29, 2001
Powered by Viper Internet

Affordable Web Hosting | ParevNet

Buy text link