Results 1 to 4 of 4
  1. #1
    dongtrien is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jul 2019
    Posts
    1

    Query numbering in groups in access database ?

    in sql server there is a group problem statement: DENSE_RANK() OVER (ORDER BY TABLUONGNV3.HOVATEN) AS STT
    How to write in sql access issues in groups? I'm not writing well: (Select Count (*) FROM [TABLUONGNV3] as Temp WHERE [Temp].[MANHANVIEN] < [TABLUONGNV3].[MANHANVIEN]) + 1 AS STT
    SELECT (Select Count (*) FROM [TABLUONGNV3] as Temp WHERE [Temp].[MANHANVIEN] < [TABLUONGNV3].[MANHANVIEN]) + 1 AS STT, TABLUONGNV3.HOVATEN, TABNHANVIEN.IDNV, TABLUONGNV3.MACANV, TABNHANVIENCA.CANV, TABLUONGNV3.N01, TABLUONGNV3.N02, TABLUONGNV3.N03, TABLUONGNV3.N04, TABLUONGNV3.N05, TABLUONGNV3.N06, TABLUONGNV3.N07, TABLUONGNV3.N08, TABLUONGNV3.N09, TABLUONGNV3.N10, TABLUONGNV3.N11, TABLUONGNV3.N12, TABLUONGNV3.N13, TABLUONGNV3.N14, TABLUONGNV3.N15, TABLUONGNV3.N16, TABLUONGNV3.N17, TABLUONGNV3.N18, TABLUONGNV3.N19, TABLUONGNV3.N20, TABLUONGNV3.N21, TABLUONGNV3.N22, TABLUONGNV3.N23, TABLUONGNV3.N24, TABLUONGNV3.N25, TABLUONGNV3.N26, TABLUONGNV3.N27, TABLUONGNV3.N28, TABLUONGNV3.N29, TABLUONGNV3.N30, TABLUONGNV3.N31, TABNHANVIENCA.TIENMOTCA, TABLUONGNV3.TONGLUONG, TABLUONGNV3.PHAT, TABLUONGNV3.TAMUNG, TABLUONGNV3.THUCNHAN, TABLUONGNV3.GHICHU
    FROM TABNHANVIENCA INNER JOIN (TABNHANVIEN INNER JOIN TABLUONGNV3 ON TABNHANVIEN.IDNV = TABLUONGNV3.MANHANVIEN) ON TABNHANVIENCA.IDCANV = TABLUONGNV3.MACANV
    WHERE TABLUONGNV3.LUONGTHANG = #06/01/2019#
    ORDER BY TABLUONGNV3.HOVATEN;
    You see the attached file: http://www.mediafire.com/file/pajlr1...ering.xls/file

  2. #2
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,043
    Hi, I'm afraid Access does not have any ranking functions. Possible solutions:
    - If your database sits on SQL-server, then create the query there in a view and link this view to your access file
    - Make a query in access and order by first the field you partition by and then the order by field in your ranking function, add a field fldRank with the constant 1. create a report based on this query and in the report you can use the RunningTotal property on the fldRank field to display the rank in the group
    - Use VBA to create a working table with all data in the proper order, add the extra ranking field and loop through the dataset to add the correct ranking
    Succes

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    not sure if it will meet your needs but access has a partition function https://support.office.com/en-us/art...7-c94278274dc5

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 1
    Last Post: 05-09-2019, 05:47 AM
  2. Add sequential numbering to groups of data
    By astephan in forum Access
    Replies: 8
    Last Post: 06-07-2018, 08:34 AM
  3. Replies: 20
    Last Post: 08-31-2016, 09:32 AM
  4. Replies: 7
    Last Post: 07-04-2014, 08:33 AM
  5. Trouble recovering database : Auto numbering
    By ArseniusCamillus in forum Access
    Replies: 4
    Last Post: 02-14-2012, 04:56 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