"johnny depp (really!)"
<nick_reyntj...@hotmail.com> wrote in
message news:22052925.p...@talk.nabble.com
> I need to group some rows, and if the values for a column are all the
> same I want to return that value,
> else I want to return "not the same".. like so:
>
> For this table:
>
> col1, col2
> A      "1"
> A      "2"
> B      "1"
> B      "1"
>
> And the query: select ..... group by col1; // can't write the query
> because I don't know it..
>
> I would like the result to be:
> col1 col2
> A     "not the same"
> B     "1"

select col1, case when min(col2) = max(col2) then col2 else 'not the 
same' end
from mytable group by col1;

Igor Tandetnik 



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to