求一資料表彙總sql語句

2022-09-14 02:20:02 字數 747 閱讀 6057

1樓:鉛杯

你是否是想這樣的結果

比如得到

碧桂園:共32,最**格:5800,最低**:5000?

如果是這樣,你可以這樣彙總

select a,sum(b),max(c),min(c)from table1

group by a

2樓:匿名使用者

select a, sum(b) 'b列彙總',case when min(c) <> max(c)then cast(min(c) as varchar(255)) +'-'+ cast(max(c) as varchar(255))

else cast(min(c) as varchar(255)) end 'c列取最大值和最小值'

from table1

group by a

3樓:匿名使用者

select a,sum(b),max(c),min(c) from table1 group by a

4樓:

select

a,sum(b),max(c),min(c)from table1

group by a

5樓:

select a , sum(b) as sum_b, max(c) as max_c, min(c) as min_c

from table1

group by a

求已篩選資料的 SQL 語句

select 月,旬別,資料 from tab where 旬別 4 union all select 月,旬別,資料 from tab t1 where 旬別 4 and not exists select 1 from tab where 月 t1.月 and 旬別 in 1,2,3 selec...

如何SQL語句就刪除表中所有的資料

用sql語句一次清空所有資料.找到了三種方法進行清空.使用的資料庫為ms sql server.表之間不能有外來鍵關係 1.搜尋出所有表名,構造為一條sql語句 declare trun name varchar 8000 set trun name select trun name trun na...

如何SQL語句就刪除表中所有的資料

刪除tablea表中的所有資料 delete from tablea sql怎麼刪除乙個表中的所有資料 刪除表資料有兩種方法 delete和truncate。具體語句如下 一 runcate table name 刪除表中的所有行,而不記錄單個行刪除操作。在這個指令之下,中的資料會完全消失,可是 本...