從復雜查詢中獲取數據到 Excel (Getting data from a complex query to excel)


問題描述

從復雜查詢中獲取數據到 Excel (Getting data from a complex query to excel)

我有一個查詢,我想依賴 Excel 工作表中的某些參數,但我收到錯誤消息“無法以圖形方式顯示的查詢中不允許使用參數”。我看到的繞過它的唯一方法是使用視圖,但這會帶來多少額外開銷?這意味著將兩張表(一張有近 70000 條記錄,一張有超過 200000 條記錄,並且都有大約 40 個字段)加入該視圖,可能只使用總共 80 個字段中的 5 個左右。我們沒有測試服務器。或者,有沒有辦法將以下查詢更改為 microsoft query 允許參數的查詢?

select count(distinct a) from table1 where b=0 and c < '2010‑01‑01' and a in 
(select a from table2 where d between '2010‑01‑01' and '2010‑12‑31') 

或作為連接:

select count(distinct table1.a) from table1 inner join table2 on (table1.a=table2.a 
and table2.d between '2010‑01‑01' and '2010‑12‑31') where table1.c < '2010‑01‑01'
and table1.b=0

我想用單元格值替換日期(對於 c 和 d)。

謝謝,

Ernst


參考解法

方法 1:

Have you considering migrate the data from Excel to SQL‑Server tables and then execute the query?. The most of the DBMS have tools for data migration.

(by ErnstArBR)

參考文件

  1. Getting data from a complex query to excel (CC BY‑SA 3.0/4.0)

#excel-2003 #sql-server-2000






相關問題

使用 VBA 根據 B 列的值重置 A 列中的值 (Reset values in column A based on the value of column B using VBA)

Пераўтварэнне формулы ячэйкі ў тэкст з дапамогай excel vba (Converting a cell's formula to text using excel vba)

刪除行並維護輸入範圍 (Delete Rows & Maintain Input Range)

從 VBA 自動排序中排除文本值 (Exclude Text Value From VBA Autosort)

Tại sao tôi không thể tạo biểu đồ này trong excel (sử dụng powershell) (Why can't I create this chart in excel (using powershell))

如何使用 VBA 從 Excel 中的公式中獲取單元格值? (How do I get the cell value from a formula in Excel using VBA?)

讓 Excel 2003 在 Word 文檔中進行查找並返回出現次數 (Have Excel 2003 do a Find in a Word document and return the number of occurences)

驗證下拉條件 (Validation Drop down on a condition)

在位於兩個不同工作表的兩個範圍內添加單元格 (Adding cells in two ranges which are located at two different sheets)

如何在excel中獲得所需的輸出? (How to get the required output in excel?)

從復雜查詢中獲取數據到 Excel (Getting data from a complex query to excel)

使用文本格式的用戶定義輸入從 excel 中檢索數據 (Retrieving data from excel with user defined input that is in text format)







留言討論