All DISTINCTs needed....

Results 1 to 2 of 2

Thread: All DISTINCTs needed....

  1. #1
    Join Date
    Dec 1969

    Default All DISTINCTs needed....

    I&#039;m trying to get all of the totals for each DISTINCT entry in the DebtorDemographics DB. So far I&#039;m only getting one entry.<BR><BR>Example: In DebtorDemographics table there are 10 different clients but only the first one is getting entered in DebtorDemographicsTotal.<BR><BR>declare @distinctClient char(6)<BR>select distinct @distinctClient = client <BR>from debtordemographics<BR><BR>declare @totCount int<BR>select @totCount = count(*) <BR>from debtordemographics <BR>where client = @distinctClient<BR><BR>insert into debtordemographicstotal (ClientNumber, TotalCount)<BR> VALUES (@distinctClient, @totCount)<BR><BR>This will run in a scheduled stored procedure.<BR><BR>-Any help is appreciated

  2. #2
    Join Date
    Dec 1969

    Default RE: All DISTINCTs needed....

    INSERT INTO debtordemographicstotal (ClientNumber, TotalCount)<BR>SELECT ClientNumber, COUNT(*) FROM debtordemographics<BR>GROUP BY ClientNumer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts