sql工具有哪些 文档加密软件排名( 二 )


SELECT vend_id,prod_name,prod_priceFROM Vendors INNER JOIN ProductsON Vendors.vend_id=Products.vend_id;SELECT prod_name,vend_name,prod_price,quantityFROM OderItems,Products,VendorsWHERE Products.vend_id=Vendors.vend_idAND OrderItems.prod_id=Products.prod_idAND order_num=20007;
自联结 在一条SELECT语句中多次使用相同的表
SELECT c1.cust_od,c1.cust_name,c1.cust_contactFROM Customers as c1,Customers as c2WHERE c1.cust_name=c2.cust_nameAND c2.cust_contact=\\\\’Jim Jones\\\\’;
8 数据透视
数据分组可以实现Excel中数据透视表的功能
数据分组
group by 用于数据分组 having 用于分组后数据的过滤
SELECT order_num,COUNT(*) as itemsFROM OrderItemsGROUP BY order_num HAVING COUNT(*)>=3;
交叉表
通过CASE WHEN函数实现
SELECT data1.city,CASE WHEN colour = \\\\”A\\\\” THEN price END AS A,CASE WHEN colour = \\\\”B\\\\” THEN price END AS B,CASE WHEN colour = \\\\”C\\\\” THEN price END AS C,CASE WHEN colour = \\\\”F\\\\” THEN price END AS FFROM data1
注:以上代码在MySQL数据库中执行