locked
how to combine my Distinct valuein query RRS feed

  • Question

  • User332347244 posted

    i want to combine all distinct rows in my query....like to display the same sentence length,person and city all together. i have been able to combine the sentence but perosn and city try to combine it gives me error.how can i combine them into distinct value.

    sentence person city
    365 Tom Washington
    30 Mark California
    365 Mark washington

    thanks in advance

    Tuesday, November 13, 2012 10:52 PM

All replies

  • User-1716253493 posted

     CONVERT(varchar, sentence) + person + city AS combined

    Tuesday, November 13, 2012 11:17 PM
  • User332347244 posted

    hi oned_gk,

    i have my query like

    select sentence, person city
    from test
    where where SentenceDate between @startdate  and @enddate.



    so how can i conver this into query

    Tuesday, November 13, 2012 11:31 PM
  • User-1716253493 posted

    I am not sure understant what you want. Would you like to explain with some sample data and output you want?

    Wednesday, November 14, 2012 1:07 AM
  • User332347244 posted

    hi oned_gk,

    i would be much grateful if you could explain with some sample data and output you provided..it will be helpful and much understandable.Cause im not sure on how to edit or change the code i have

    thanks in advanceWink

    Wednesday, November 14, 2012 1:48 PM
  • User2105670541 posted

    try to use a query like below:

    select distinct convert(varchar,sentence+ ' '+ person+ ' '+ city) as details
    from test
    where where SentenceDate between @startdate  and @enddate.



    Monday, November 19, 2012 12:54 AM