0

My goal is to select value from "EmbedImgDimension" column where in lots of duplicated values are present.

I have used the following query

select
  distinct EmbedImgId,
  VideoID,
  EmbedImgHeight,
  EmbedImgWidth,
  EmbedImgFileName,
  concat(embedimgwidth,' x ',embedimgheight) as EmbedImgDimension
  from embedimages
  inner join Video on Video.schoolid=#Value#
  where embedimages.isdeleted=0 order by embedimages.embedimgwidth asc;

wat modification should i make in this query so as to select unique values from the "EmbedImgDimension" column.Any help would be deeply appreciated.

Thanks.

2 Answers 2

3
  select
  distinct concat(embedimgwidth,' x ',embedimgheight) as EmbedImgDimension
  from embedimages
  inner join Video on Video.schoolid=#Value#
  where embedimages.isdeleted=0 order by embedimages.embedimgwidth asc;

update

saying you also want distinct video ids is a logical problem. you want to get a result in which each dimension appears only once, right? then, how can you expect to also get all the distinct videoID results? imagine you have

videoid  dimension
      1        1x1
      2        1x1
      3        2x2
      4        2x2

maybe you can tell me which result you'd like to get. but you're either going to get 1x1 and 2x2, or you're going to get 1,2,3,4 - the moment you want dimension uniqueness, you can't also get all the distinct videoids, see what I mean?

Sign up to request clarification or add additional context in comments.

4 Comments

if you want to get distinct values, you have to remove the non-distinct values (like video_ids). the way you put it now, the database tries to find distinct combinations of video_id, EmbedImgId, and so on (which are probably unique so you won't get any groupings)
@nicolas78: thanks pal... but i also need to implement select distinct EmbedImgId, VideoID, EmbedImgHeight, EmbedImgWidth, EmbedImgFileName in my query... so wat can be done...
check out my update. I think you want the logically impossible but maybe you can elaborate further
prly you just need several queries.
1

Use the distinct keyword on the EmbedImgDimension column.

2 Comments

can u explain to me the modification that has to be made in the current query
e.g. select distinct (concat ("test", col_name)) from table_name

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.