Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create table mytable (c1 string,c2 string);
- insert into mytable values ('A','A'),('B',null),('C',null);
- select count(distinct c1) as count_distinct from mytable;
- +----------------+
- | count_distinct |
- +----------------+
- | 3 |
- +----------------+
- select count(distinct concat(c1,c2)) as count_distinct from mytable;
- +----------------+
- | count_distinct |
- +----------------+
- | 1 |
- +----------------+
- select c1,c2,concat(c1,c2) as concat_c1_c2 from mytable;
- +----+------+--------------+
- | c1 | c2 | concat_c1_c2 |
- +----+------+--------------+
- | A | A | AA |
- | B | NULL | NULL |
- | C | NULL | NULL |
- +----+------+--------------+
- select count(distinct c1,c2) as count_distinct from mytable;
- +----------------+
- | count_distinct |
- +----------------+
- | 1 |
- +----------------+
- select distinct c1,c2 from mytable;
- +----+------+
- | c1 | c2 |
- +----+------+
- | B | NULL |
- | A | A |
- | C | NULL |
- +----+------+
- select count(distinct struct(c1,c2)) as count_distinct from mytable;
- +----------------+
- | count_distinct |
- +----------------+
- | 3 |
- +----------------+
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement