You must Sign In to post a response.
  • Category: SQL Server

    Group by Expression in sql server query

    Hi ,

    SELECT
    FIDFUNDSUMMARY.PROGRAMCODE,
    FIDFUNDSUMMARY.CASENUM,
    FIDFUNDSUMMARY.CLAPAYTRANNUM,
    FIDFUNDSUMMARY.PAYMENTAMT,
    FIDFUNDSUMMARY.LASTNAME,
    FIDFUNDSUMMARY.FIRSTNAME,
    FIDUCIARYFUNDS.APPLIEDAMT,
    FIDUCIARYFUNDS.CLAPAYTRANNUM,
    FIDUCIARYFUNDS.TYPE,
    FIDUCIARYFUNDS.CHECKDATE,
    CLAIMTRANH.PAYEENAME,
    CLAIMTRANH.FUNDSREQDATE,
    FIDFUNDSUMMARY.LEVEL1ORG
    FROM
    (TPA.FIDFUNDSUMMARY FIDFUNDSUMMARY INNER JOIN TPA.FIDUCIARYFUNDS FIDUCIARYFUNDS
    ON ((((FIDFUNDSUMMARY.LEVEL1ORG=FIDUCIARYFUNDS.LEVEL1ORG)
    AND
    (FIDFUNDSUMMARY.PROGRAMCODE=FIDUCIARYFUNDS.PROGRAMCODE))
    AND (FIDFUNDSUMMARY.CASENUM=FIDUCIARYFUNDS.CASENUM))
    AND (FIDFUNDSUMMARY.CLAPAYTRANNUM=FIDUCIARYFUNDS.CLAPAYTRANNUM))
    AND (FIDFUNDSUMMARY.TRANDATE=FIDUCIARYFUNDS.TRANDATE))
    INNER JOIN CLM.CLAIMTRANH CLAIMTRANH
    ON ((((FIDFUNDSUMMARY.LEVEL1ORG=CLAIMTRANH.LEVEL1ORG)
    AND
    (FIDFUNDSUMMARY.CASENUM=CLAIMTRANH.CASENUM))
    AND (FIDFUNDSUMMARY.CLAPAYTRANNUM=CLAIMTRANH.CLAPAYTRANNUM))
    AND (FIDFUNDSUMMARY.PROGRAMCODE=CLAIMTRANH.PROGRAMCODE))
    AND
    (FIDUCIARYFUNDS.CHECKBATCHNUM=CLAIMTRANH.CHECKBATCHNUM)
    WHERE FIDFUNDSUMMARY.LEVEL1ORG=2000 AND FIDUCIARYFUNDS.TYPE<>'rv'

    ORDER BY FIDFUNDSUMMARY.PROGRAMCODE, FIDUCIARYFUNDS.CLAPAYTRANNUM


    In this query i need implement group by

    GROUP BY FIDFUNDSUMMARY.PROGRAMCODE,FIDFUNDSUMMARY.CLAPAYTRANNUM,FIDUCIARYFUNDS.CHECKDATE

    but it showing error..

    Please help this query.
  • #762389
    Hi Sriram,

    Please mention what type error you are getting while execute this above query, so that others can provide you exact solution.

    Thanks,
    Ram Prasad

  • #762391
    Hi

    Whats the error message you are getting?
    And also provide at which line of your query you are getting error, so that we can understand easily can can give solution.

    Regards

    Sridhar Thota.

    Sridhar Thota.
    Editor: DNS Forum.

  • #762399
    Hi Sriram,

    I guess you are getting error like "Column '' is invalid in the select list because it is not contained in either an aggregate function or Group by column". If you are getting error like above the solution for this is Whenever you can use Grouping clause you just remind one thing what are all the columns are you using in select statement must and should be their in Grouping clause or Aggregate functions. If you maintain this obviously you can avoid this type of errors, if you are getting different error, then please share your error details to us. So, that we can help you to resolve that.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


Sign In to post your comments