Help whit Query Distinct

  • Hi,

    I have a query thats brings me:

    dsCallId Piloto

    ---------- ---------------------------------

    1005833038ACD_EPMBOGOTA_VENTAS_COMERCIAL

    1005833038Leidy Tatiana Montes Acevedo

    1005833888ACD_EPMBOGOTA_VENTAS_COMERCIAL

    1005833888Leidy Tatiana Montes Acevedo

    1005834868ACD EPM Bogota Ventas

    1005834868Deisy Carolina Presiga Bustamante

    1005835307ACD_EPMBOGOTA_VENTAS_COMERCIAL

    1005836847ACD EPM Bogota Ventas

    1005837669ACD EPM Bogota Ventas

    1005837669Edison Alexis Neira Cadavid

    the columns dsCallId and Piloto are varchar.

    Im using the following code to get the data above.

    Select distinct A.dsCallId, A.Piloto

    From

    (

    Select

    dsCallId,

    Piloto

    From

    SPS01_CALLBACK.[DB_Callback_CM].[dbo].[tbl_Datos_LLamadaEntrantesEPMBog]

    Where

    fechaLlamada between '2010-01-22' and '2010-01-22 12:00:00'

    and dsCallId not in ('') and Piloto not in ('')

    ) A,

    (

    Select

    CALLID as Identificador

    From

    DB_Recordges.dbo.History_recordges

    Where

    recordingdate between '2010-01-22' and '2010-01-22 12:00:00'

    and

    assignedworkgroup in ('NA','Not Found','Timed out or not in queue')

    ) B

    Where

    A.dsCallId = B.Identificador COLLATE Latin1_General_CI_AS

    I need a query to to bring me the data like this:

    dsCallId Piloto

    ---------- ---------------------------------

    1005833038ACD_EPMBOGOTA_VENTAS_COMERCIAL

    1005833888ACD_EPMBOGOTA_VENTAS_COMERCIAL

    1005834868ACD EPM Bogota Ventas

    1005835307ACD_EPMBOGOTA_VENTAS_COMERCIAL

    1005836847ACD EPM Bogota Ventas

    1005837669ACD EPM Bogota Ventas

    thank you any help to solve this.

  • Are you sure that your statement is correct? You don't use "B" anywhere. (BTW: Try to get rid of this old join-style)

    Greets

    Flo

  • add

    AND A.Piloto LIKE 'ACD%'

    to your WHERE clause.

    If that's not what you're looking for please provide sample data and expected results as described in the first link in my signature.

    @Flo: Glad to see you around again! Where have you been?



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • Hey Lutz!

    lmu92 (1/28/2010)


    @Flo: Glad to see you around again! Where have you been?

    Been busy last time. It's always hard for a (primary) .net-dev to stay too much in sql. It's my passion :-P, sadly, not my primary business and I had to get up-to-date with some new .net stuff. I still have to...

    Also didn't feel very well in my current company. Tomorrow I'll quit my contract and in three month I'm away from there 😀

    Greets

    Flo

  • lmu92 (1/28/2010)


    add

    AND A.Piloto LIKE 'ACD%'

    to your WHERE clause.

    If that's not what you're looking for please provide sample data and expected results as described in the first link in my signature.

    @Flo: Glad to see you around again! Where have you been?

    Thank You all, Thank you lmu92 that should do the trick.

Viewing 5 posts - 1 through 4 (of 4 total)

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