Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2010
    Posts
    22

    Unanswered: Query to get Output

    The below is the data in a table:
    Code:
    Name	Cost	SoldAmt	SoldBill
    A1	5	8	22
    B2	1		
    A1	8	15	21
    C3	5	10	20
    A1	7	8	R2
    A1	8		
    A1	5	3	D2
    B2	3	2	18
    B2	3		
    C3	1
    For all the Items whose SoldBill start with either 'D' or 'R', I need the count

    I need the Ouput as below:

    Code:
    Name	Count of Return
    A1	2
    B2	0
    C3	0
    I wrote a query which gives output as

    Code:
    Name	Count of Return
    A1	2
    Its not giving the Ouput for rows whose count is zero.

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Code:
    ...SUM(iif(LEFT(SoldBill, 1) IN("D", R"), 1, 0) AS [Count of Return]....
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Feb 2010
    Posts
    22
    Can you please provide the exact query, I couldn't fit it.

    Thanks for your help.

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Post what you've got and I'll edit it.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Feb 2010
    Posts
    22
    Sorry, it worked!
    I missed one of the bracket.

    Thanks a lot.

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Oops - my error. Aircode....
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

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