dcsimg
Results 1 to 5 of 5

Thread: [RESOLVED] Count when greater that zero

  1. #1

    Thread Starter
    Frenzied Member schoemr's Avatar
    Join Date
    Apr 2016
    Location
    South Africa
    Posts
    1,077

    Resolved [RESOLVED] Count when greater that zero

    Hi,

    In a datagridview I display users as well as total tasks every user have done. I have added a manual DataColumn in the dataset designer and set the source to Expr1:

    Code:
    SELECT        COUNT(tblTaskContext.NameOfTask) AS Expr1, TblUsers.UserID, TblUsers.FirstName, TblUsers.LastName
    FROM            TblUsers LEFT OUTER JOIN
                             tblTaskContext ON TblUsers.UserID = tblTaskContext.UserID
    WHERE        TblUsers.UserTypeID <> 3
    This is working well, but it is also displaying users that did not do any tasks (lots of "0"'s) I only want to see users that have at least one task?

    Thanks
    Don't miss the whole point of the dance...

    https://www.youtube.com/watch?v=qHnIJeE3LAI

  2. #2
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,327

    Re: Count when greater that zero

    Change the left join to an inner join. That should filter out any rows that don't have a record in tblTaskContext
    You can depend upon the Americans to do the right thing. But only after they have exhausted every other possibility - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

  3. #3

    Thread Starter
    Frenzied Member schoemr's Avatar
    Join Date
    Apr 2016
    Location
    South Africa
    Posts
    1,077

    Re: Count when greater that zero

    Quote Originally Posted by FunkyDexter View Post
    Change the left join to an inner join. That should filter out any rows that don't have a record in tblTaskContext
    Thank you Funky!!!
    Don't miss the whole point of the dance...

    https://www.youtube.com/watch?v=qHnIJeE3LAI

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    102,746

    Re: [RESOLVED] Count when greater that zero

    It's a small thing but I would change 'Expr1' to something meaningful like 'TaskCount'.

  5. #5

    Thread Starter
    Frenzied Member schoemr's Avatar
    Join Date
    Apr 2016
    Location
    South Africa
    Posts
    1,077

    Re: [RESOLVED] Count when greater that zero

    Quote Originally Posted by jmcilhinney View Post
    It's a small thing but I would change 'Expr1' to something meaningful like 'TaskCount'.
    Hi John, Yes I should. Thank you
    Don't miss the whole point of the dance...

    https://www.youtube.com/watch?v=qHnIJeE3LAI

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width