Results 1 to 7 of 7
  1. #1
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    409

    Cannot group by query


    Hi, i'm not able to group by date (a.data) this query

    Code:
    SELECT a.CF AS CFbase, a.data AS Data_base, (SELECT cf FROM qryassoreti as a1 WHERE a1.data=a.data AND a1.azienda = a.azienda and  a1.tipo = a.tipo)-(SELECT cf FROM qryassoreti as a1 WHERE a1.data=dateadd("M",-1,a.data) AND a1.azienda = a.azienda and  a1.tipo = a.tipo) AS [+- CF], Format((SELECT cf FROM qryassoreti as a1 WHERE a1.data=a.data AND a1.azienda = a.azienda and  a1.tipo = a.tipo)/(SELECT cf FROM qryassoreti as a1 WHERE a1.data=dateadd("M",-1,a.data) AND a1.azienda = a.azienda and  a1.tipo = a.tipo)-1,"Percent") AS [% CF], (SELECT Totale FROM qryassoreti as a2 WHERE a2.data=a.data AND a2.azienda = a.azienda and  a2.tipo = "Stock") AS StockBaseFROM qryassoreti AS a
    WHERE (((a.data)>=[MASCHERE]![Aziende]![datainiziotb] And (a.data)<=[MASCHERE]![Aziende]![datafinetb]) AND ((a.azienda)=[Maschere]![Aziende]![Azienda])) OR (((a.data)<=[MASCHERE]![Aziende]![datafinetb]) AND ((a.azienda)=[Maschere]![Aziende]![Azienda]) AND (([MASCHERE]![Aziende]![datainiziotb]) Is Null)) OR (((a.data)>=[MASCHERE]![Aziende]![datainiziotb]) AND ((a.azienda)=[Maschere]![Aziende]![Azienda]) AND (([MASCHERE]![Aziende]![datafinetb]) Is Null)) OR (((a.azienda)=[Maschere]![Aziende]![Azienda]) AND (([MASCHERE]![Aziende]![datainiziotb]) Is Null) AND (([MASCHERE]![Aziende]![datafinetb]) Is Null))
    ORDER BY a.data;
    can you help me? tell me if you need more infos, thanks

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Is date in date format or String? numeric date format will sort correctly.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    You mean you can't ORDER by date? What field data type is a.data?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    409
    nevermind, the source of data is the problem.
    i have to change that, however, the pic shows the result i get, and i need to group by dateClick image for larger version. 

Name:	Immagine 2023-08-10 111140.png 
Views:	18 
Size:	66.2 KB 
ID:	50627

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Use an aggregate query - in query design it’s on the ribbon

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Grouping at what level? By the combination of AziendaBase/CFBase/Data_base? What do you want to do with the +/- and % fields? Maybe should build a report and use its Sorting & Grouping features with aggregate calcs. This allows display of detail data as well as summary info.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    409
    thanks both, now i'm pretty proficient in sql, i did a grouping but i got a strange error base on the source query. I just have to incorporate the precedent sql
    thanks

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

Similar Threads

  1. Replies: 2
    Last Post: 02-20-2019, 10:45 PM
  2. Replies: 2
    Last Post: 11-26-2016, 01:07 PM
  3. Replies: 6
    Last Post: 06-09-2015, 09:51 AM
  4. Replies: 0
    Last Post: 02-25-2013, 04:43 PM
  5. query group by over another group by?
    By gap in forum Queries
    Replies: 2
    Last Post: 07-04-2011, 12:59 AM

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