Query error

  • Error:  Column 't1.AccountNumber' is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause. If I add group by I get Column 't1.AccountNumber' is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause.

    THANKS

    Select   t1.AccountNumber

                    , t1.originalBilledAmount / t3.ProcRecords As AdjBilledAmt

                    , t2.PatientPrimaryKey

                    , PhysicianID

                    , t2.cptcode

    From  tbl_BillingMaster t1

    Inner Join tbl_PerformedProcedure t2

      On  t1.PatientPrimaryKey = t2.PatientPrimaryKey

    Inner Join

     (Select  t1.AccountNumber

       , Cast(Count(*) As decimal) As ProcRecords

     From  tbl_BillingMaster  t1

     Inner Join tbl_PerformedProcedure  t2

       On  t1.PatientPrimaryKey = t2.PatientPrimaryKey

     Where  billingcoveredfromdate Between '2003-01-01' And '2003-12-31')

      As t3

      On  t1.AccountNumber = t3.AccountNumber

  • Select   t1.AccountNumber

                    , t1.originalBilledAmount / t3.ProcRecords As AdjBilledAmt

                    , t2.PatientPrimaryKey

                    , PhysicianID

                    , t2.cptcode

    From  tbl_BillingMaster t1

    Inner Join tbl_PerformedProcedure t2

      On  t1.PatientPrimaryKey = t2.PatientPrimaryKey

    Inner Join

     (Select  t1.AccountNumber

       , Cast(Count(*) As decimal) As ProcRecords

     From  tbl_BillingMaster  t1

     Inner Join tbl_PerformedProcedure  t2

       On  t1.PatientPrimaryKey = t2.PatientPrimaryKey

     Where  billingcoveredfromdate Between '2003-01-01' And '2003-12-31'

    group by t1.AccountNumber)

      As t3

      On  t1.AccountNumber = t3.AccountNumber

     

    Just guessing given that I can't duplicate your query; this is where the problem is in any event.  Look there.

  • THanks that did !! I keep looking at the first one.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply