简体   繁体   English

我如何从另一个元素选择中获得 select 属性

[英]How do I select attributes from another selection of elements

I am using Excel's Power Query in order to test a SQL query that I am eventually going to use in order to make a pivot table that stays updated with the database.我正在使用 Excel 的 Power Query 来测试 SQL 查询,我最终将使用该查询来制作与数据库保持更新的 pivot 表。 The database is accessed through an ODBC.该数据库通过 ODBC 访问。

The problem is not related to Power Query itself but simply the SQL request.该问题与 Power Query 本身无关,而与 SQL 请求无关。 Here I am trying to select all bills from the "facturation" (French database) table that are from the current year (2021).在这里,我正在尝试 select 来自当前年份(2021 年)的“facturation”(法国数据库)表中的所有账单。 I am naming this selected data FACTURES_ANEE_COURANTE.我将这个选定的数据命名为 FACTURES_ANEE_COURANTE。

Then I want to also select some attributes of those items from 2021 in order to display them in the pivot table, but only on the selection that I just made in order to only select (and show) bills from the current year.然后我还想 select 从 2021 年起这些项目的一些属性,以便在 pivot 表中显示它们,但仅限于我刚刚做出的选择,以便仅显示当前年份的 Z99938282F04071859941E18F16EF 账单。

select * as FACTURES_ANNEE_COURANTE 
from facturation 
where year(date_fact)=2021 limit 3, select date_fact from FACTURES_ANNEE_COURANTE

I only have very basic knowledge of SQL and therefore this does not seem to work, the second part of my request that is (the first one works).我只有非常基本的 SQL 知识,因此这似乎不起作用,我要求的第二部分是(第一个有效)。 I'm trying to do this in order to be able to show these specific attributes in the pivot table.我试图这样做是为了能够在 pivot 表中显示这些特定属性。 What's the proper way to select attributes only from my first selection of elements from my table facturation? select 属性的正确方法是仅从我的表构造中选择的第一个元素中?

Thank you for your help.谢谢您的帮助。

A major advantage of Power Query is being able to generate complex logic without needing to be able to code in SQL. Power Query 的一个主要优势是能够生成复杂的逻辑,而无需在 SQL 中进行编码。 So I would abandon writing hand coded SQL - there's no need.所以我会放弃手写编码 SQL - 没有必要。

Before PQ came out I had 2 decades of experience writing complex SQL.在 PQ 出现之前,我有 2 年编写复杂 SQL 的经验。 After PQ came out I've written almost none - the SQL code generated by PQ is good enough, you can easily add complex transformations that are hard/impossible in SQL, and overall developing and debugging is 10x easier. PQ 出来后我几乎没有写过——PQ 生成的 SQL 代码已经足够好了,您可以轻松地添加在 SQL 中难以/不可能的复杂转换,并且整体开发和调试容易 10 倍。

For your scenario, I would build a PQ query just using the navigation to select your facturation table.对于您的场景,我将使用导航到select您的分解表来构建 PQ 查询。 Then I would use the PQ UI to Filter (instead of a SQL where clause) and Choose Columns (to restrict the columns returned).然后我会使用 PQ UI 来过滤(而不是 SQL where 子句)并选择列(以限制返回的列)。

Whatever other transformations you need are likely met using a button in the PQ UI.使用 PQ UI 中的按钮可能会满足您需要的任何其他转换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM