Sql command to read a specific sheet, column

This is probably a very stupid question for SQL stalwarts, but I just need one SQL command.

More details

I use a data analysis tool called R, this tool uses ODBC to read data from XLS. Now I am trying to read data from an XLS file. The ODBC tool in R accepts SQL commands.

Question

Can someone give me an SQL command that will read data from an XLS file? - Specified sheet - Specified column [by name] - Specified row [Specified only by row index]

Thanks...

+3
source share
3 answers

, :

select [columnname] from [sheetname$] where [columnname] = 'somevalue'

. where, .

+3

61 cloumn A, G G.

SELECT * FROM [Sheet1$a61:G]
+5

:

SELECT [sheet1$.col1], [sheet1$.col2], [sheet2$.col1] 
FROM   [sheet1$], [sheet2$] 
WHERE  [sheet1$.col1] = [sheet2$.col2]

Excel (sheet1 sheet2). 2 , (col1 col2 ).

:

> library(RODBC)
> conn <- odbcConnectExcel('c:/tmp/foo.xls')
> query <- "select [sheet1$.col1], [sheet1$.col2], [sheet2$.col1] 
            from [sheet1$], [sheet2$] 
            where [sheet1$.col1] = [sheet2$.col2];"
> result <- sqlQuery(conn, query)
> odbcClose(conn)
> result
  col1 col2 col1.1
1    1    3      5
2    2    4      6
3    3    5      7

. . , .

+3

Source: https://habr.com/ru/post/1713816/


All Articles