Results 1 to 9 of 9
  1. #1
    LudovicV is offline Novice
    Windows 10 Office 365
    Join Date
    Apr 2023
    Posts
    4

    Lightbulb Question about filtering / SQL for a table

    Hello there, I'm new here so I hope I post it on the right place

    I have this table :


    Click image for larger version. 

Name:	2023-04-14_11h30_29.png 
Views:	18 
Size:	18.3 KB 
ID:	50107

    As you can see, the sum of the column "Difference" for the entry "JOHN DOE" equals 0 (for example).

    I would like to filter this table so that "JOHN DOE" does not appear on the table.

    Is it possible with a filter or a SQL query ?

    Thank you in advance and best wishes.



    LudovicV
    Last edited by LudovicV; 04-14-2023 at 03:32 AM. Reason: my table doesn't appear

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    [identity]<>"john doe"

  3. #3
    LudovicV is offline Novice
    Windows 10 Office 365
    Join Date
    Apr 2023
    Posts
    4
    Quote Originally Posted by ranman256 View Post
    [identity]<>"john doe"
    Sorry I wasn't very precise : I'd like to delete entries with the sum = 0 and the entries are often changing.

    The ending result should be that :

    Click image for larger version. 

Name:	2023-04-14_14h18_32.png 
Views:	14 
Size:	3.3 KB 
ID:	50111

    Thank you in advance for your help.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,570
    Code:
    SELECT Transactions.Description, Sum(Transactions.Amount) AS SumOfAmount
    FROM Transactions
    GROUP BY Transactions.Description
    HAVING (((Sum(Transactions.Amount))<>0));
    Adjust your fieldnames to suit.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    LudovicV is offline Novice
    Windows 10 Office 365
    Join Date
    Apr 2023
    Posts
    4
    Quote Originally Posted by Welshgasman View Post
    Code:
    SELECT Transactions.Description, Sum(Transactions.Amount) AS SumOfAmount
    FROM Transactions
    GROUP BY Transactions.Description
    HAVING (((Sum(Transactions.Amount))<>0));
    Adjust your fieldnames to suit.
    Ok it did work but I lost the other columns ("Account", "Record", etc.) and I want to keep them, is it possible ?

    Thank you

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,570
    Quote Originally Posted by LudovicV View Post
    Ok it did work but I lost the other columns ("Account", "Record", etc.) and I want to keep them, is it possible ?

    Thank you
    You select those fields as well if you need them. As they are the same (well at least in the picture you showed) then the grouping will still work.
    I was only showing the logic.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    LudovicV is offline Novice
    Windows 10 Office 365
    Join Date
    Apr 2023
    Posts
    4
    Yeah I can see the logic but OK forget about the "Account" column, the others are different, is there a possibility to keep them (with a JOIN command maybe) ?

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,570
    Quote Originally Posted by LudovicV View Post
    Yeah I can see the logic but OK forget about the "Account" column, the others are different, is there a possibility to keep them (with a JOIN command maybe) ?
    No.
    I would identify a field that you can refer to.
    Put that in the groupby query.
    Then use that query as a sub query where that field is NOT IN that query.

    There might be a one query way, but I do not know of it.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  9. #9
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,425
    Deleting records often turns out to be a bad idea. Also, what you have there is a calculated table field - also often a bad idea. Getting off of my soap box now...

    Methinks if in a Totals query you group by Identity, have SumOfDebit, SumOfCredit, subtract the 2 in another query field and set the criteria as = 0 for that field. Or if you only want to see one particular Identity, add that criteria. Untested and from my coffee starved brain...
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 06-04-2015, 09:48 AM
  2. Filtering Question
    By cbende2 in forum Access
    Replies: 8
    Last Post: 08-04-2014, 12:32 PM
  3. Form filtering question
    By jscriptor09 in forum Access
    Replies: 1
    Last Post: 04-11-2012, 03:39 PM
  4. Filtering Records Question
    By manic in forum Programming
    Replies: 5
    Last Post: 04-03-2012, 08:48 AM
  5. Question on filtering a form
    By jbarrum in forum Forms
    Replies: 12
    Last Post: 02-15-2010, 11:38 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums