Oracle uses shell to test historical data samples

Source: Internet
Author: User

Oracle uses shell to test historical data samples

Shell has been used to analyze some data for some time, and the data analysis is based on historical data. Today, I wrote a script to perform a simple analysis of historical data, see how accurate it is.

Here is a script 12c. sh used to analyze the percentage of some data. For example, there are two teams today. The main team gives the ball one, and the probability of winning or losing is 35%, 40%, 25%.

Table data contains some sample data, which records the team's game status.


Sqlplus-s n1/n1 <EOF
Set linesize 150
Set pages 0
Set feedback off
Spool check _ $ 1.sh
Select 'ksh 12c. sh' | w | ''| t |'' | l | ''| rw |'' | rt | ''| rl | ''from data where r =-1 and startdate = '$1 ';
Spool off;

EOF

Ksh check _ $ 1.sh | tee check _ $ 1.log
Grep suggest check _ $ 1.log | awk '{print $7 "" $8 "" $9 "" $10 "" $11 "$12" "$1" "$ 2 "" $3 "" $4 "" $5 "" $6} '> filter_check.log

Cat filter_check.log

Function get_result
{
Echo $1
Sqlplus-s n1/n1 <EOF
Set pages 0
Select case when zhu> ke + 1
Then rpad ('Big win: ', 20) | to_number (w + rw) | ''|' $ 2' | ', '|' $ 3' | ',' | '$ 4' |', '|' $ 5' | ', '|' $ 6' | ',' | '$7'
When zhu = ke + 1
Then rpad ('little win: ', 20) | to_number (w + rt) | ''|' $ 2' | ', '|' $ 3' | ',' | '$ 4' |', '|' $ 5' | ', '|' $ 6' | ',' | '$7'
When zhu = ke
Then rpad ('tie: ', 20) | to_number (t + rl) | ''|' $ 2' | ', '|' $ 3' | ',' | '$ 4' |', '|' $ 5' | ', '|' $ 6' | ',' | '$7'
When zhu = ke-1
Then rpad ('little lose: ', 20) | to_number (l + rl) | ''|' $ 2' | ', '|' $ 3' | ',' | '$ 4' |', '|' $ 5' | ', '|' $ 6' | ',' | '$7'
When zhu <ke-1
Then rpad ('Big lose: ', 20) | to_number (l + rl) | ''|' $ 2' | ', '|' $ 3' | ',' | '$ 4' |', '|' $ 5' | ', '|' $ 6' | ',' | '$7'
End
End from data where startdate = '$ 1' and w = $2 and t = $3 and l = $4 and rw = $5 and rt = $6 and rl = $7 order by (zhu-ke );
EOF
}

While read line
Do
Echo --- start
Echo $ line
Input_params = 'echo $ line | awk '{print $1 "" $2 "" $3 "" $4 "" $5 "" $6 }''
Get_result $1 $ input_params
Echo... end
Echo.
Done <filter_check.log


Rm check _ $ 1.log
Rm filter_check.log
Rm check _ $ 1.sh


The analysis results are as follows. For example, if I have no idea about the results of the competition.
Three were guessed in five games for entertainment only.

--- Start
1.24 5.35 7.6 1.8 3.75 3.28 suggest w: 82% of total 11
2014-08-26
Little win: 4.99 1.24, 5.35, 7.6, 1.8, 3.75, 3.28

... End
.
--- Start
1.18 5.85 9.4 1.65 3.9 3.75 suggest w: 71% of total 17
2014-08-26
Tie: 9.6 1.18, 5.85, 9.4, 1.65, 3.9, 3.75

... End
.
--- Start
1.43 4.15 5.42 2.42 3.4 2.38 suggest w: 65% of total 97
2014-08-26
Little lose: 7.8 1.43, 4.15, 5.42, 2.42, 3.4, 2.38

... End
.
--- Start
2.1 2.95 3.25 4.7 3.6 1.57 suggest rl: 68% of total 50
2014-08-
Tie: 4.52 2.1, 2.95, 3.25, 4.7, 3.6, 1.57

... End
.
--- Start
1.1 6.75 15 1.45 4.2 4.95 suggest w: 80% of total 5
2014-08-26
Big win: 2.55 1.1, 6.75, 15, 1.45, 4.2, 4.95

... End

Install Oracle 11gR2 (x64) in CentOS 6.4)

Steps for installing Oracle 11gR2 in vmwarevm

Install Oracle 11g XE R2 In Debian

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.