Results 1 to 2 of 2

Thread: SQL query in ACCESS

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    22

    SQL query in ACCESS

    Hi, I need some help with my ACCESS SQL query.
    I have a tbl_Main, which records daily transactions for all the clients.
    i need to find a summary of top 20 clients with their sum of income with a ranking column.
    what i did is I use two queries to get the result.
    1.
    SELECT TOP 25 tbl_main.[Client Name], Sum(tbl_main.Income) AS [Total Income]
    FROM tbl_main
    GROUP BY tbl_main.[Client Name]
    ORDER BY Sum(tbl_main.Income) DESC;
    (This query is just to find the client with income in a groupby version, the name of this query is "qry_Client")

    2.
    SELECT (SELECT COUNT(*) from [qry_client] WHERE [qry_client].income > country.income)+1 AS Rank, *
    FROM qry_Client AS country;
    (This sub-query is to add the ranking column)

    My goal is to combine this two queries into one single query, is it possible?
    thanks a lot in anticipation.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: SQL query in ACCESS

    I've never seen anything for that which works in a single query I'm afraid - which means it's probably not possible (otherwise I would have seen it in the DB forum at some point).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width