1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
| select ssex from student;
select all ssex from student;
select distinct ssex from student;
select distinct ssex,sname,sbirth from student;
select * from student where 1>2; select * from student where 1=1;
select * from student where sname="李勇";
select * from student where length(sname)>2;
select sid from student where (sid)>95005 group by sid;
select count(sid) from student;
select count(sid) from student where sname = "李峰";
select sum(sid) from student where sname = "李峰";
select length("itcast"); select reverse("itcast"); select concat("angela","baby");
select concat_ws('.', 'www', array('itcast', 'cn'));
select substr("angelababy",-2); select substr("angelababy",2,2);
-select split('apache hive', ' ');
select current_date();
select unix_timestamp();
select unix_timestamp("2011-12-07 13:01:03");
select unix_timestamp('20111207 13:01:03','yyyyMMdd HH:mm:ss');
select from_unixtime(1618238391); select from_unixtime(0, 'yyyy-MM-dd HH:mm:ss');
select datediff('2012-12-08','2012-05-09');
select date_add('2012-02-28',10);
select date_sub('2012-01-1',10);
select round(3.1415926);
select round(3.1415926,4);
select rand();
select rand(3);
select * from student limit 3;
select if(1=2,100,200); select if(sex ='男','M','W') from student limit 3;
select nvl("allen","itcast"); select nvl(null,"itcast");
select case 100 when 50 then 'tom' when 100 then 'mary' else 'tim' end; select case sex when '男' then 'male' else 'female' end from student limit 3;
create table user_access ( group_id string, createtime string, pv int )row format DELIMITED FIELDS TERMINATED BY ','; load data local inpath '/export/data/hivedata/group_access.txt' into table user_access;
select group_id, createtime, pv, rank() over(partition by createtime order by pv desc) AS rn1, dense_rank() over(partition by createtime order by pv desc) as rn2, row_number() over(partition by createtime order by pv desc) as rn3 from user_access;
select group_id, createtime, pv, rank() over(partition by createtime order by pv desc) AS rn1, dense_rank() over(partition by createtime order by pv desc) as rn2, row_number() over(partition by createtime order by pv desc) as rn3 from user_access;
|