Results 1 to 2 of 2
  1. #1
    rajaindia is offline Novice
    Windows 8 Access 2007
    Join Date
    Jan 2017
    Posts
    1

    Exclamation MS Access- SQL queries help

    Hi


    I have been trying to solve these MS access SQL queries but unable to get the output . I have attached the query which I tried and the database structure for referencce..
    Please help me in getting the correct answer asap !

    Thanks !
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    1. UNION is certainly not appropriate. JOIN tables and apply filter criteria:

    WHERE Publisher = "Vintage Books" OR Branch="JM Brentwood"

    2. This requires aggregate (GROUP BY) subquery. JOIN appropriate tables and apply filter criteria:

    WHERE Book_Code IN (SELECT Book_Code FROM Wrote GROUP BY Book_Code HAVING Count(*) = 2)

    3. Again, a subquery can be used:

    WHERE Branch_Num = JM Brentwood number AND Book_Code IN (SELECT Book_Code FROM Copy WHERE Branch_Num = JM on the Hill number)

    4. This one gets complicated. First build a query of Copy that returns DISTINCT book codes for each branch. Then use that query to do an aggregate query that counts these DISTINCT records for each branch. Join that to Book and apply filter criteria:

    WHERE CountOfBooks = (SELECT Max(CountOfBooks) FROM CountQuery)

    There is possibility of a tie between branches for the most titles.


    Hope that gets you in the right direction, pulling these from top of my head as no data available to test. Provide database with sample data if you want more help.
    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.

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

Similar Threads

  1. Access SQL queries
    By Lshamz in forum Access
    Replies: 3
    Last Post: 12-15-2015, 08:27 PM
  2. New to Access - Help with Queries
    By KFF in forum Queries
    Replies: 1
    Last Post: 08-19-2015, 10:03 AM
  3. Replies: 6
    Last Post: 11-13-2013, 04:17 PM
  4. Need help with Access Web Queries
    By markarmer in forum Queries
    Replies: 0
    Last Post: 02-22-2013, 08:28 AM
  5. Queries in access
    By genobee in forum Queries
    Replies: 1
    Last Post: 11-01-2011, 06:04 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