简体   繁体   中英

SQL in Excel - Multiple levels of filters

I having problems with a sql query I need to do.

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.

For example: Filter Size 3 in Category A and Subcategory AB. 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.

If it is not possible then I will do it in 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. I must say that your description is not intelligable by me so it's possible that you ment something else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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