码迷,mamicode.com
首页 > 数据库 > 详细

简单SQL操作

时间:2017-09-04 11:06:07      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:min   信息   mpi   strftime   blog   and   sel   cas   mint   

以前学SQL的时候,只会简单的增删查改,然后什么课设,毕设都是增删查改,想想好智障~ 

1.从表中选取出不同的值

select distinct company from order;

2.返回列的最大值

select MAX(column_name) from table_name;

3.返回某列信息的不同值的最大值

select *
from (
select food,max(prince) prince from order
group by food 
)order;

4.周六日的平均气温

select AVG(meantempi)
from(
select * from weather_date where cast(strftime (%w,date)
as integer) IN (6,0)
)weather_date;

5.找出平均气温大于55是雨天的平均最低气温

select AVG(mintempi)
from(
select * from weather_data 
where mintempi > 55 and rain = 1
)weather_data;

简单SQL操作

标签:min   信息   mpi   strftime   blog   and   sel   cas   mint   

原文地址:http://www.cnblogs.com/chenyang920/p/7472363.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!