[英]SQL in Excel - Multiple levels of filters
I having problems with a sql query I need to do. 我在执行sql查询时遇到问题。
Basically, I have the following table: 基本上,我有下表:
Company Country Code Category Subcategory Size
Express USA USYOU1 A AB 2
Candy Canada CAN109 A AB 2
NoGlobal France OM1983 B BC 3
BigBos Germany GE9839 A AC 3
Hose USA US894 A AB 3
Comp USA USCOM2 A AB 4
Flower USA FLUSI21 A AB 4
Sausa Germany GESAU29 B AB 2
I would like to filter by Size rows were Category is A and Subcategory is AB and show the rest as the are. 我想按大小来过滤,类别为A,子类别为AB,其余按原样显示。
For example: Filter Size 3 in Category A and Subcategory AB. 例如:类别A和子类别AB中的过滤器大小3。 My final table would be something like this:
我的决赛桌将是这样的:
Company Country Code Category Subcategory Size
NoGlobal France OM1983 B BC 3
BigBos Germany GE9839 A AC 3
Hose USA US894 A AB 3
Sausa Germany GESAU29 B AB 2
This is giving me quite a problem to do, my knowledge in SQL is limited, I managed to do this using two queries and using a UNION later, but I would like to do all of this in Excel 2013's Microsoft Query SQL editor. 这给我带来了一个很大的问题,我对SQL的了解有限,我设法使用两个查询并在以后使用UNION进行了此操作,但是我想在Excel 2013的Microsoft Query SQL编辑器中完成所有这些操作。
If it is not possible then I will do it in Access 2013 如果不可能,那么我将在Access 2013中进行操作
I don't know if I am giving enough information, users can change the size to filter at their whim, but I want that Size filter to apply only to the categories I am specifying (the user can only change the size filter). 我不知道我是否能提供足够的信息,用户可以随意更改大小以进行过滤,但是我希望“大小”过滤器仅适用于我指定的类别(用户只能更改大小过滤器)。
Your example is consistent with the clause 您的示例与该子句一致
WHERE (Size = 3 OR Category <> 'A' OR Subcategory <> 'AB')
You can actually type this in in microsoft Query (press the SQL button) and it will appear in the criteria window. 您实际上可以在Microsoft Query中键入此内容(按SQL按钮),它将显示在条件窗口中。 I must say that your description is not intelligable by me so it's possible that you ment something else.
我必须说,您的描述对我来说是无法理解的,因此您可能会提出其他建议。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.