Results 1 to 2 of 2
  1. #1
    sathyguy is offline Novice
    Windows XP Access 2007
    Join Date
    May 2013
    Posts
    1

    Question Grouping Query getting multiple rows in access with vb6

    friends...

    can anybody check this query and tell me where i am making mistake...i have to get a single row for each record...but i am getting mutiple rows...this is ms-access query with vb6 as front end.

    Code:
    "select [stdentry.sno],[stdentry.branch],[stdentry.stdname],[stdentry.amtobepaid]," _
    & "iif([feesdetail.paytype]='DD',sum([feesdetail.paidamt]),0) as totpaid," _
    & "iif([feesdetail.paytype]='CASH',sum([feesdetail.paidamt]),0) as totpaid1 " _
    & "from stdentry,feesdetail where " _
    & "([feesdetail.delstat]='N') and [stdentry.sno]=[feesdetail.sno] and [stdentry.refundstat]='N' " _
    & "group by [stdentry.sno],[stdentry.branch],[stdentry.stdname],[stdentry.amtobepaid],[feesdetail.paytype]"



    thanks and waiting for somebody's help.

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    You're using 2 tables that I can see:

    STDENTRY
    FEESDETAIL

    You are grouping on 5 fields

    STDENTRY.SNO
    STDENTRY.BRANCH
    STDENTRY.STDNAME
    STDENTRY.AMTOBEPAID
    FEESDETAIL.PAYTYPE

    One of these fields has multiple records per client, my guess is that it's your feesdetail table since I would guess that you only have one record per student in your STDENTRY table. So, look at your FEESDETAIL table and see if you do, in fact, have multiple paytypes. (I suspect you do since you're dealing with them differently in your query). If you only have 2 pay types DD or CASH you are already handling those in your query and you do not need to have the PAYTYPE in your query at all, you can remove that field from your query and from your GROUP BY statement.

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

Similar Threads

  1. Replies: 1
    Last Post: 05-14-2012, 04:12 AM
  2. insert multiple rows in access
    By learning_graccess in forum Queries
    Replies: 1
    Last Post: 03-31-2012, 10:15 AM
  3. Query on multiple rows
    By TPH in forum Access
    Replies: 10
    Last Post: 09-02-2011, 12:52 PM
  4. Grouping and Transapose rows with columns
    By HendriX99 in forum Queries
    Replies: 3
    Last Post: 03-14-2011, 03:23 PM
  5. Replies: 11
    Last Post: 09-02-2010, 01:59 PM

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