Equivalent to Joining tables (SQL) in Excel?

Click For Summary
SUMMARY

This discussion focuses on the methods for performing operations similar to SQL joins within Excel, particularly when dealing with data from multiple sheets. Users explore various techniques, including using formulas like =A_table!A1/B_table!B1 for direct calculations and leveraging PivotTables for data consolidation. The conversation highlights the advantages of exporting Excel data to SQL Server for more complex queries and the challenges faced with Microsoft Query connections. Best practices suggest using SQL Server for data storage and Excel primarily for reporting and analysis.

PREREQUISITES
  • Understanding of Excel formulas, particularly referencing cells across sheets
  • Familiarity with PivotTables and their functionalities in Excel
  • Basic knowledge of SQL Server and its Import/Export Wizard
  • Experience with Microsoft Query and ODBC connections in Excel
NEXT STEPS
  • Learn how to create and manipulate PivotTables in Excel for data analysis
  • Explore the SQL Server Import/Export Wizard for data migration from Excel
  • Investigate the use of ODBC connections to perform SQL queries directly in Excel
  • Study the implementation of calculated fields in PivotTables for advanced calculations
USEFUL FOR

Data analysts, Excel users, and SQL Server professionals looking to integrate Excel with SQL for enhanced data manipulation and reporting capabilities.

  • #31
WWGD said:
Ah, never mind. In case anyone is interested for the SQL format:
We want to compute the ratio SUM(f_1)/COUNT(f_2) , f1 in table 1 (T1), f2 in table 2 (T2);
f_12 a common field , over values in f_12 common to T1, T2.
This runs: EDIT

SELECT A/B FROM
( SELECT SUM(f_1) AS A
FROM T1 JOIN T2 on T1.f_12=T2.f_12 GROUP BY f_12) AS Table1
JOIN
(SELECT COUNT(f_2) AS B FROM T1 JOIN T2 ON T1.f_12=T2.f_12
GROUP BY f_12 ) AS Table2
ON Table1.f_12 =Table2.f_12
GROUP BY f_12

Sorry to all for dragging this along so far.

Have you found a solution yet?
I do sql in Excel now and then (ODBC) using some time sheets in the same file as tables, but also sometime sheets in differents files.
I know you can do simple join operations. See this link with some .xlsx examples and a ReadMe.txt file:
https://www.dropbox.com/sh/awoes8lgpj76igb/AABZOAEq7pF36kIXKykn3PKga?dl=0

In file T_Queries, I put A and B in different columns and did A/B the old school Excel way in a formula but you can play around with more complex join queries and see how Excel handles it.. (Ribbon > Data > Connections > DoubleClick on Connection > Definition).
Those two queries use tables/sheets being in the same file (T_1_and_2.xlsx).

Another query, just for fun, uses tables/sheets being in 2 different files (T_1.xlsx and T_2.xlsx).
It's cool that one can use a virtual database of excel files being all over the place and query it using our dear friends SQL and ODBC!

Let us know it this helps a little in what you were trying to achieve.
 
Last edited:
  • Like
Likes   Reactions: WWGD
Computer science news on Phys.org
  • #32
Tokinabo said:
Have you found a solution yet?
I do sql in Excel now and then (ODBC) using some time sheets in the same file as tables, but also sometime sheets in differents files.
I know you can do simple join operations. See this link with some .xlsx examples and a ReadMe.txt file:
https://www.dropbox.com/sh/awoes8lgpj76igb/AABZOAEq7pF36kIXKykn3PKga?dl=0

In file T_Queries, I put A and B in different columns and did A/B the old school Excel way in a formula but you can play around with more complex join queries and see how Excel handles it.. (Ribbon > Data > Connections > DoubleClick on Connection > Definition)

Those two queries use tables/sheets being in the same file (T_1_and_2.xlsx).
Another query, just for fun, uses tables/sheets being in 2 different files (T_1.xlsx and T_2.xlsx).

Let us know it this helps a little in what you were trying to achieve.
Thanks. I was able to do it in SQL , but I had trouble using Microsoft query within Excel; somehow the connection was not working well ( despite the fact that the Wizard had no trouble sending data back-and-forth). Thanks for your refs., will check them out.
 

Similar threads

Replies
11
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
6
Views
2K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 51 ·
2
Replies
51
Views
6K
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K