用access和excel進行資料分析總結

來源:果殼範文吧 2.97W

#資料庫操作(如表的合併,跨表查詢,統計最大最小數值等)適合用access完成

用access和excel進行資料分析總結

#excel適合處理二維表,對單元格的簡單計算,如下是典型的二維表


600600600601600602600603600604

青島啤酒方正科技廣電電子ST興業二紡機
2002-1-47.4613.0210.0411.089.27
2002-1-77.3112.99.9211.18.85
2002-1-87.312.999.9511.118.73
2002-1-97.1912.9210.0411.448.25
2002-1-107.3512.9410.0911.958.4
2002-1-117.2812.669.7711.688.04
2002-1-147.0812.019.511.547.73
2002-1-156.9912.028.9511.347.67
2002-1-167.1511.998.9311.157.88
2002-1-176.9111.588.410.047.19
2002-1-186.911.378.29.346.9

#一般思路: 對於原始的excel表,先利用access的SQL語句進行分組,排序,跨表合併

根據具體要求再利用excel的`公式或VBA完成其他複雜的功能

幾點經驗:

ss中要進行跨表查詢,必須先建立"關係",可使用工具->關係選單進行設定

2. 常見SQL語句

a)最大最小,排序處理

SELECT AFE_cast_Stkcd, AFE_, Min(AFE__DAYS_ELAPSED) AS RAW_DAYS_ELAPSED之最小值, Max(AFE__DAYS_ELAPSED) AS RAW_DAYS_ELAPSED之最大值

FROM AFE_statv2ACCURACY

GROUP BY AFE_cast_Stkcd, AFE_

ORDER BY AFE_cast_Stkcd, AFE_;

b)刪除資料

DELETE *

FROM AFE_statv2無空項

WHERE AFE_statv2無空項cast_AFE最大值=AFE_statv2無空項cast_AFE最小值

c) 表的連線:

INNER JOIN保留公共資料,LEFT JOIN和RIGHT JOIN分別完整保留左,右表資料,必要時通過DISTINCT引數去除重複的記錄

d)日期函式 Year等

3. excel VBA程式碼分析

Public Sub firstVBA()

Dim thisdate As Date

Dim wday As Integer

Dim rno As Integer

Dim stkcd As String

Dim ananm As String

Dim findStk1 As Range

Dim findStk2 As Range

Dim findStk3 As Range

Dim findStk6 As Range

Dim findStk7 As Range

Dim findStk8 As Range

Dim findStk9 As Range

Dim findStk10 As Range

Dim findIndex As Range

Dim findDate As Range

Dim TwoDayB As Integer

Dim TwoDayA As Integer

Dim OneDayB As Integer

Dim OneDayA As Integer

Dim FindCol As Integer

Dim CR_FIVE As Double

Dim CR_THREE As Double

Dim Revp As Double

Dim indexTwoDayB As Integer

Dim indexTwoDayA As Integer

Dim indexOneDayB As Integer

Dim indexOneDayA As Integer

Dim CR_Index_FIVE As Double

Dim CR_Index_THREE As Double

Sheet11是最終存放結果的表,Sheet1-3,6-10存放了各日各股票的價格,sheet5存放上證,深證指數

For rno = 2 To 6864

stkcd = e("A" & rno)e 查詢股票程式碼

thisdate = e("E" & rno)e 查詢日期

Set findStk1 = e("1:1")(stkcd)

Set findStk2 = e("1:1")(stkcd)

Set findStk3 = e("1:1")(stkcd)

Set findStk6 = e("1:1")(stkcd)

Set findStk7 = e("1:1")(stkcd)

Set findStk8 = e("1:1")(stkcd)

Set findStk9 = e("1:1")(stkcd)

Set findStk10 = e("1:1")(stkcd)

查詢股票在哪張表中

If Not findStk1 Is Nothing Then

Set findStk = findStk1

Sheets("sz_stk1")ct

ElseIf Not findStk2 Is Nothing Then

Set findStk = findStk2

Sheets("sz_stk2")ct

ElseIf Not findStk3 Is Nothing Then

Set findStk = findStk3

Sheets("sz_stk34")ct

ElseIf Not findStk6 Is Nothing Then

Set findStk = findStk6

Sheets("sh_stk1")ct

ElseIf Not findStk7 Is Nothing Then

Set findStk = findStk7

Sheets("sh_stk2")ct

ElseIf Not findStk8 Is Nothing Then

Set findStk8 = findStk8

Sheets("sh_stk3")ct

ElseIf Not findStk9 Is Nothing Then

Set findStk = findStk9

Sheets("sh_stk4")ct

ElseIf Not findStk10 Is Nothing Then

Set findStk = findStk10

Sheets("sh_stk5")

熱門標籤