熟练掌握xss语录(xss写入一句话)

今日热点 2022年05月31日
本文导读目录:

sql中如何使用语句

use Tempdb

go

-- --

if not object_id('xssj') is null

drop table xssj

Go

Create table xssj([unitcode] int,[operator] nvarchar(2),[money] int,[type] nvarchar(5))

Insert xssj

select 1,N'小文',2400,N'团购' union all

select 2,N'小李',3400,N'经销' union all

select 3,N'小文',1200,N'经销' union all

select 5,N'小李',3500,N'团购' union all

select 9,N'小王',4900,N'名烟名酒店' union all

select 12,N'小刘',1200,N'团购' union all

select 14,N'小文',5000,N'批发' union all

select 19,N'小文',9000,N'团购'

Go

Select [operator],

[团购]=sum(case when [type]=N'团购' then [money] else 0 end),

[经销]=sum(case when [type]=N'经销' then [money] else 0 end),

[批发]=sum(case when [type]=N'批发' then [money] else 0 end),

[合计]=sum([money])

from xssj group by [operator]

operator 团购 经销 批发 合计

-------- ----------- ----------- ----------- -----------

小文 11400 1200 5000 17600

小王 0 0 0 4900

小李 3500 3400 0 6900

小刘 1200 0 0 1200

(4 个资料列受到影响)

动态这样就行了

declare @s nvarchar(4000)

set @s='select [operator]'

select @s=@s+','+quotename([type])+N'=sum(case when [type] = N'''+[type]+''' then [money] else 0 end)'

from xssj group by [type]

exec(@s+N',sum([money]) as 合计 from xssj group by [operator]')

8行SQL语句中请大侠翻译!

是不是xscp里面有xsmc xsbh cpbh.?

经销商经销的的商品决定于表 xscp?

当以上答案为真,那么我有一点看法:

SELECT xsmc from xscp where cpbh

IN(

select cpbh from xscp where xsmc =

(

select xsmc form xscp where xsbh ='000001'

)

);

思路就是这样,如果有问题请楼主补充,我再作更改~

我也想对这个题目了解多一点,标准答案里面xscp1 xscp2 xscp3那里暂时还理解不到必要性,同望高手作答

***************************

是不是如果000001号单的是经销商A经销产品,查到A共经销了产品

1 2 3 4 5号产品,那么符合题目要求的经销商就是经销了 1 2 3 4 5号产品或者1 2 3 4 5 6 .........(更多) 的经销商??

请问怎么在SQL执行这条语句

是SQL server,还是oracle?

如果是sqlserver,打开SSMS,登录服务器,然后新建查询,选择数据库,在查询窗口里输入这个SQL语句,执行一下就可以了。

如果是oracle,使用sqlplus联接数据库,直接执行就可以了。

用T-SQL语句自定义一表值函数

declare @sql varchar(8000)

set @sql='select * from '

if flag=1

set @sql=@sql+'CP1'

if flag=2

set @sql=@sql+'XSS1'

if flag=3

set @sql=@sql+'XSCP1'

exec(@sql)

sql 语句操作三个表

很简单的,三个表关联下再sum、group下就可以了。

表及其表中字段命名如下:

销售单

表(XSJL)

商品编码

(SPCODE)

金额(XSJE)

时间(XSSJ)

仓位号(CWH)

商品表(SP)

商品编码(SPCODE)

厂商编码(CSCODE)

厂商表(CSB)

厂商编码(CSCODE)

厂商名称

(CSNAME)

查询语句:

select

C.CSCODE,C.CSNAME,SUM(A.XSJE)

from

XSJL

A

,SP

B

,CSB

C

WHERE

A.SPCODE=B.SPCODE

AND

B.CSCODE=C.CSCODE

GROUP

BY

C.CSCODE,C.CSNAME

我来说两句
黑客技术 2年前 (2022-05-31) | 回复
,4900,N'名烟名酒店' union allselect 12,N'小刘',1200,N'团购' union allselect 14,N'小文',5000,N'批发' union allselect
黑客技术 2年前 (2022-05-31) | 回复
union allselect 2,N'小李',3400,N'经销' union allselect 3,N'小文',1200,N'经销' union allselect 5,N'小李',3500,N'团购' union allselect 9,N'小王',4900,N'名烟名酒店'
黑客技术 2年前 (2022-05-31) | 回复
rom xssj group by [type]exec(@s+N',sum([money]) as 合计 from xssj group by [operator]
黑客技术 2年前 (2022-05-31) | 回复
------小文 11400 1200 5000 17600小王 0 0 0 4900小李 3500