Results 1 to 2 of 2
  1. #1
    waqas is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    117

    Cool sub queries

    Dear Experts,i am trying to count OFF, Sick leave, Annual leave in seprate columns using sub queries but it become slow and when i scroll down the it is hangedcan someone tell me how to write query are a different method to do same.SELECT TblTimeSheetTest.IDNUM, Format([SDay],"mmm") AS Mnth, Sum(TblTimeSheetTest.NHrs) AS SumOfNHrs, Sum(TblTimeSheetTest.OTHrs) AS SumOfOTHrs, Sum(TblTimeSheetTest.PreHrs) AS SumOfPreHrs, Sum(TblTimeSheetTest.TotalHrs) AS SumOfTotalHrs, (SELECT count(offalias.tanda) from tbltimesheettest as offalias where offalias.tanda = "OFF" and offalias.idnum = tbltimesheettest.idnum) AS OFF, (SELECT count(offalias.tanda) from tbltimesheettest as offalias where offalias.tanda = "Sick Leave" and offalias.idnum = tbltimesheettest.idnum) AS SL, (SELECT count(offalias.tanda) from tbltimesheettest as offalias where offalias.tanda = "Annual Leave" and offalias.idnum = tbltimesheettest.idnum) AS ALFROM TblTimeSheetTestGROUP BY TblTimeSheetTest.IDNUM, Format([SDay],"mmm");

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,728
    The references often cited as the authority on subqueries is Allen Browne's material.

    http://allenbrowne.com/subquery-01.html
    http://allenbrowne.com/subquery-02.html

    Good luck

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

Similar Threads

  1. Sub Queries
    By waqas in forum Queries
    Replies: 5
    Last Post: 01-24-2012, 11:48 AM
  2. VBA vs Queries
    By TheDeceived in forum Access
    Replies: 6
    Last Post: 12-16-2011, 06:11 AM
  3. Sum Queries
    By Lilsug in forum Access
    Replies: 4
    Last Post: 12-17-2010, 08:45 AM
  4. Queries
    By MeganDoak in forum Queries
    Replies: 3
    Last Post: 04-22-2010, 12:13 AM
  5. how i can run a sum queries
    By ahmed-aljawad in forum Queries
    Replies: 3
    Last Post: 04-17-2010, 11:06 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