1. 程式人生 > >簡單SQL操作

簡單SQL操作

rom order cast blog ftime company mpi avg and

以前學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操作