Home > database >  SQL how different index statistics monthly, according to the nature, and according to the line arran
SQL how different index statistics monthly, according to the nature, and according to the line arran

Time:09-24

Help you a great god!!!!!!
In need for a number of different indicators according to the monitor, so you need to use SQL to do a query result set, as the chart to a case when functions like, but I don't know how to achieve:
Metric names in January February march April may
PV
UV
The purchasing amount
Orders
The guest unit price

The existing data table in the general situation is as follows:
Table A: user id in order for the amount of the order id order

Table B: date PV UV

CodePudding user response:

Table A and table B associated fields? Which field is the guest unit price?

CodePudding user response:

reference 1st floor belsai response:
table A and table B associated fields? Which field is the guest unit price?


No associated fields, is want to ask different logical calculation index, how to horizontally arranged on a monthly basis

CodePudding user response:

 SELECT * FROM [StudentScores]/* */data source 
AS P
The PIVOT
(
The SUM (Score/* row after row of values */) FOR
P. ubject/* need to row column */IN ([language], [math], [English], [life]/* value */column)
) AS T
  • Related