摘要:create table sdata.dbo. t_access_times(username varchar(255),month varchar(255),salary int)insert into sdata.dbo.t_access_times values ('A','2016-01',
阅读全文
摘要:create table sdata.dbo.onetest( Order_Source_Name varchar(255),Plant_Location_Number varchar(255),Plant_Location_Name varchar(255),Booked_Date varchar
阅读全文
摘要:求10月在哪个季度 select CEILING(convert(real,10)/3) REPLACE 下例用 xxx 替换 abcdefghi 中的字符串 cde。 SELECT REPLACE(''abcdefghicde'',''cde'',''xxx'')GO下面是结果集: abxxxfg
阅读全文
摘要:--根据EMP_ID求bug最多的--select EMP_ID,COUNT(1) bug_count,convert(varchar(7),DATE_FOUND,120) month_buginto sdata.dbo.emp_idbioafrom sdata.dbo.ERD_BUG awhere
阅读全文
摘要:查询出没门课程都大于80的学生的姓名 select name from table group by name having MIN(fenshu)>80 编号自增:identity(1,1) 删除除了编号以后,其他信息相同的信息自动编号 学号 姓名 课程名称 分数1 200 张三 数学 892 2
阅读全文
摘要:delete from sdata.dbo.mo_money insert into sdata.dbo.mo_money values ('mo','1000','2018-06-08') insert into sdata.dbo.mo_money values ('mo','12000','2
阅读全文
摘要:delete from sdata.dbo.mo_moneyinsert into sdata.dbo.mo_moneyvalues('make','3000','2018-06-12')insert into sdata.dbo.mo_moneyvalues('alex','400','2018-
阅读全文
摘要:--加载算法-- --全量覆盖 hive的写法是 insert overnrite table 表名 --sql 的写法是 select 字段名称 as 字段名称新 from 表名 增量追加 先删除p层里面的数据 delete from 表名 where 条件 inse into 表明 select
阅读全文
摘要:表值函数 返回一张表 SELECT * FROM sdata.dbo.taobaocarDROP function dbo.subd_day use pmartgocreate function dbo.subd_day(@priov varchar(255))returns tableas ret
阅读全文
摘要:select * from sdata.dbo.cost_detaildrop table sdata.dbo.cost_detail_now --根据SERVICE_ORDER_LINE 取最小的值 因为一个订单 可能换的很多零件,只统计一个--select * into sdata.dbo.co
阅读全文
摘要:select * from sdata.dbo.taobaoda --根据省市统计 cost的总钱数,收藏宝贝的数量,收藏店铺的数量,加入购物车的数量,点击的次数--select priov,city,SUM(cost) cost,SUM(baby)*0.2 baby,SUM(shop)*0.3 s
阅读全文
摘要:1、row_number() over()排序功能: (1) row_number() over()分组排序功能: 在使用 row_number() over()函数时候,over()里头的分组以及排序的执行晚于 where group by order by 的执行。 partition by 用
阅读全文
摘要:having 语句 WHERE 子句对被选择的列施加条件,而 HAVING 子句则对 GROUP BY 子句所产生的组施加条件。 SQL > SELECT ID, NAME, AGE, ADDRESS, SALARY FROM CUSTOMERS GROUP BY age HAVING COUNT(
阅读全文
摘要:--单子国家品牌日期 订单数select country_id ,product_group_ops --,case when service_order_creation_date ='00:00.0' then null -- else CAST(service_order_creation_d
阅读全文
摘要:select * from sdata.dbo.month_rateselect MAX(SERVICE_ORDER_CREATION_DATE) from sdata.dbo.cost_detailselect * from sdata.dbo.billing_data update sdata.
阅读全文
摘要:-更新数据 下面的换成上面的--update sdata.dbo.billing_data set Product_Group_Ops ='APPLE2'where Product_Group_Ops ='OPPO'update sdata.dbo.billing_data set Product_
阅读全文
摘要:--day05基础-- create table sdata.dbo.open_order( Order_Source_Name nvarchar(255) ,Plant_Location_Number nvarchar(255) ,Plant_Location_Name nvarchar(255)
阅读全文
摘要:create table #mian2( cola int,colb int,colc int) insert into #mian2 values (1,2,3)insert into #mian2 values (5,2,3)insert into #mian2 values (5,9,3) 表
阅读全文
摘要:--join连接-- --新建表t1--drop table sdata.dbo.t1create table sdata.dbo.t1(id int,name varchar(255) ) insert into sdata.dbo.t1(id,name)values('1','lucy')ins
阅读全文
摘要:--day02主键-- drop table sdata.dbo.testday02create table sdata.dbo.testday02(bw_id int primary key, -- 主键的关键字 即表里面的数据不能完全一致--bw_no varchar (50) not null
阅读全文
摘要:/****** Script for SelectTopNRows command from SSMS ******/--day01基础知识--SELECT TOP 1000 [CustomerID] ,[CustomerName] ,[ContactName] ,[Address] ,[City]
阅读全文