(依訂單日期列出各機種的訂單量總和資料)
select pro_id, sum(quan), order_date from sales2 group by pro_id, order_date order by order_date
列出92年2月份以前各機種的訂單量總和資料)
select pro_id, sum(quan), order_date from sales2 where order_date < 920201 group by pro_id, order_date order by order_date
列出月間的所有訂單資料)
select from sales2 s, customer c,
product p where ( 920228 and < 920501) and ( and =
列出月間的所有訂單資料) (此範例以下皆以中文欄位名稱顯示)
select as 客戶編號, as 客戶名稱, as 業務名稱, as 產品編號, as 產品名稱, as 數量, as 訂單日期 from sales2 s, customer c, product p where ( 920228 and < 920501) and ( and =
依訂單日期列出所有的訂單資料)
select as 產品編號, as 產品名稱, sum( as 數量, as 訂單日期 from sales2 s, customer c, product p where = and = group by order by
列出各機種的總訂單量)
select as 產品編號, as 產品名稱, sum( as 數量 from sales2 s, customer c, product p where = and = group by
列出各機種的總訂單量及單價)
select as 產品編號, as 產品名稱, as 單價, sum( as 數量 from sales2 s, customer c, product p where = and = group by
列出各機種的總訂單量及金額並依照金額大小由小至大排列)
select as 產品編號, as 產品名稱, as 單價, sum( as 數量, sum( *as 總金額 from sales2 s, customer c, product p where = and = group by order by 總金額。
列出各機種的最小及最大訂單量)
select as 產品編號, as 產品名稱, min( as 最小數量, max( as 最大數量 from sales2 s, product p where = group by
列出業務員向大鵬在月間各機種的業績金額)
select as 產品編號, as 產品名稱, as 單價, sum( as 數量, sum( *as 總金額 from sales2 s, customer c, product p where ( and = and = 向大鵬’ and ( 920101 and <=920228) group by
列出業務員向大鵬的總業績金額)
select as 業務名稱, sum( *as 總金額 from sales2 s, product p where = and = 向大鵬’ group by
列出業務員向大鵬在月間的總業績金額)
select as 業務名稱, sum( *as 總金額 from sales2 s, product p where = and = 向大鵬’ and ( 920101 and <=920228) group by
列出a0012這家客戶的所有交易資料)
select as 客戶編號, as 客戶名稱, as 業務名稱, as 產品編號, as 產品名稱, as 數量, as 訂單日期 from sales2 s, customer c, product p where = a0012’ and ( and =
列出a0012這家客戶單筆交易量在1000套以上的所有交易資料)
select as 客戶編號, as 客戶名稱, as 業務名稱, as 產品編號, as 產品名稱, as 數量, as 訂單日期 from sales2 s, customer c, product p where = a0012’ and ( and = and > 1000
列出a0012這家客戶的所有交易筆數)
select count(*)as 筆數 from sales2 where cus_id = a0012’
如何以sql語法在資料庫中搜尋完全符合tedit 欄位的值。
if <>then
f_f_'select as 訂單編號, as 批號, as 銷貨日期, as 銷貨數量 from rood01 d, rosa01 s');
f_' where =
f_' and = f_f_
如何以sql語法在資料庫中搜尋部份符合tedit 欄位的值(效果與前段符合相同).
if <>then
f_f_'select as 訂單編號, as 批號, as 銷貨日期, as 銷貨數量 from rood01 d, rosa01 s');
f_' where like ''
f_' and =f_
sql语法
知识要点 1 transact sql运算符 1 算术运算符。注 null与任何值运算结果为null。运算可用于datetime型数据。2 字符串运算符。3 比较运算符。逻辑常量 ture false。4 逻辑运算符。not 非 and 与 or 或 between 指定范围 like 模糊匹配 5...
SQL语法
distinct 输出唯一值。select distinct from where between and 介于某一范围的数据。where 某行 between and in 属于某一子集合的数据。where 某行 in substring expression 开始位 长度 选取字符串。selec...
SQL语法
一 create table 数据表是数据库中储存数据的基本架构。举例来说,如果我们有一个记载顾客数据的数据表,那字段包括姓名 地址 城市 国家 生日 等等。当我们对数据表下定义时,我们需要注明字段名称,以及那个字段的类型。字段类型可能是一个整数 例如 1 一个实数 例如 0.55 一个字符串 例如...