Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. create table mytable (c1 string,c2 string);
  2. insert into mytable values ('A','A'),('B',null),('C',null);
  3.  
  4. select count(distinct c1) as count_distinct from mytable;
  5.  
  6. +----------------+
  7. | count_distinct |
  8. +----------------+
  9. | 3 |
  10. +----------------+
  11.  
  12. select count(distinct concat(c1,c2)) as count_distinct from mytable;
  13.  
  14. +----------------+
  15. | count_distinct |
  16. +----------------+
  17. | 1 |
  18. +----------------+
  19.  
  20. select c1,c2,concat(c1,c2) as concat_c1_c2 from mytable;
  21.  
  22. +----+------+--------------+
  23. | c1 | c2 | concat_c1_c2 |
  24. +----+------+--------------+
  25. | A | A | AA |
  26. | B | NULL | NULL |
  27. | C | NULL | NULL |
  28. +----+------+--------------+
  29.  
  30. select count(distinct c1,c2) as count_distinct from mytable;
  31.  
  32. +----------------+
  33. | count_distinct |
  34. +----------------+
  35. | 1 |
  36. +----------------+
  37.  
  38. select distinct c1,c2 from mytable;
  39.  
  40. +----+------+
  41. | c1 | c2 |
  42. +----+------+
  43. | B | NULL |
  44. | A | A |
  45. | C | NULL |
  46. +----+------+
  47.  
  48. select count(distinct struct(c1,c2)) as count_distinct from mytable;
  49.  
  50. +----------------+
  51. | count_distinct |
  52. +----------------+
  53. | 3 |
  54. +----------------+
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement