Home > database >  SQL procession into
SQL procession into

Time:11-09

 
Use mscore
Select SUM (SCORE_PFSCORE) as a, MAX (SCORE_RYID) as b, MAX (SCORE_NAME) as c,
MAX (SCORE_PFDL_NAME) as d

-, MAX (SCORE_PFXL_NAME)
The from SCORE
Where SCORE_PFSD='GBHX20200817020438'

Group by SCORE_PFDL_ID, SCORE_RYID


Such SQL statements, the result as follows


Whether through the transformation, such results
Name number of politics professional achievements in negative listing work dealt with accountability combined
Zhang SAN 0001 15 13-15-20 47 54
Li si 0002 0 0 0 0 0 0

CodePudding user response:

Project only political landscape professional achievements in negative listing work by accountability to deal with these things fixed?

CodePudding user response:

reference 1st floor qq_37753824 response:
project only political landscape professional achievements in negative listing work by accountability to deal with these things fixed?


No, may be change from time to time

CodePudding user response:

 
Select * from s

Turn - 2: dynamic stitching line column
DECLARE @ SQL VARCHAR (8000)
SET @ SQL='SELECT name, class,'
SELECT SQL + SQL=@ @ 'SUM (CASE subjects WHEN' ' '+ subject +' ' 'THEN achievement ELSE 0 END) AS' ' '+ QUOTENAME (subject) +' ' ', '
The FROM (FROM the SELECT DISTINCT subject s) AS a
SELECT @ SQL=LEFT (@ SQL, LEN (@ SQL) - 1) + 'FROM s GROUP BY name, class'
PRINT (@ SQL)
The EXEC (@ SQL)
GO

CodePudding user response:

Combined with the
 
Turn - 2: dynamic stitching line column
DECLARE @ SQL VARCHAR (8000)
SET @ SQL='SELECT name, class,'
SELECT SQL + SQL=@ @ 'SUM (CASE subjects WHEN' ' '+ subject +' ' 'THEN achievement ELSE 0 END) AS' ' '+ QUOTENAME (subject) +' ' ', '
The FROM (FROM the SELECT DISTINCT subject s) AS a
SELECT @ SQL=LEFT (@ SQL, LEN (@ SQL) - 1) + ', the sum (grades) combined the FROM s GROUP BY name, class '
PRINT (@ SQL)
The EXEC (@ SQL)
GO

CodePudding user response:

Please try this inside the method of transformation of two kinds of methods to share

CodePudding user response:

reference 5 floor qq_25073223 reply:
please try this method ranks the transformation in two ways to share


Learning, for me to study
  • Related