SQL does not have row conversion columns:
The ideal result is that the groupName with Objectid 77 is merged into one row.
Finally, let's look at the page effects of js processing.
Some friends may ask different results. I modified the data later.
Normal row-column conversion (version 1.0) only provides static and dynamic writing for SQL server 2000, and version 2.0 adds SQL server 2005 writing.
Question: Suppose there is a student orders table (tb) as follows:
Name course score
Zhang San
1. Column and column conversion-common
Assume that there is a student summary table (CJ) as follows:Name subject resultZhang San Chinese 80Zhang San, mathematics 90Zhang San physical 85Li Si Chinese 85Li Si mathematics 92Li Si physical 82
Want to
I recently wrote a Sales Report SQL statement to summarize this type of two-dimensional SQL statement.
Table Structure Test
Productname salemonth salenumber
A M1 1
B M1 1
A m2 2
B m2 3
Query results are required:
Productname M1 m2
A 1 2
B 1 3
Method
First reference a blog address: http://www.cnblogs.com/luluping/archive/2009/07/24/1530611.html
The SQL statement is generated and executed dynamically by dynamically combining case statements.
I am here to read the following:First, how to
(1) display and sort row numbers
1. SQL Server row number
A. SQL 2000 uses identity (int,) and temporary tables to display row numbers.SELECTIdentity (int, 1, 1) as rownum,[DataID]INTO #1FROM DATASOrder by DataID;SELECT * FROM #1B. SQL 2005
Recently in the project, the user gave a few reports of the needs of the data need to be summarized. In this process, a method for row-to-column SQL statements is used. So what should be done?The process in the project is more complex, I'll build a
Pivot is used to rotate column values to column names (row to column), and SQL Server 2000 can be implemented with an aggregate function with a case statementThe general syntax for pivot is: Pivot (aggregate function (column) for column in (...)) As
Before processing the data, did not consider the use of row-to-column, more using the creation of temporary tables, after the use of destruction, today encountered a tricky problem, the use of temporary tables is very complex, so the use of
Reprint: http://www.cnblogs.com/newwind521/archive/2010/11/25/1887203.htmlSQL row Line column conversion for normal row/*Title: Normal row and column conversions (version 2.0)Aixinjueluo. Yuk WahDate: 2008-03-09Location: Shenzhen,
How to dynamically number rows and add row numbers in SQL is a classic problem in database queries.
How to dynamically number rows and add row numbers in SQL is a classic problem in database queries.
(1) display and sort row numbers
1. SQL Server
Normal row-column conversion (version 1.0) only provides static and dynamic writing for SQL Server 2000, and Version 2.0 adds SQL Server 2005 writing.
Question: Suppose there is a student orders table (TB) as follows:
Name course score
Zhang
Create Table TEM (ID int identity (1, 1) primary key, name nvarchar (30), result nvarchar (6) insert into TEM (name, result) values ('Jim ', 'win') insert into TEM (name, result) values ('Jim ', 'win') insert into TEM (name, result) values ('Jim',
For a simple table, there are two rows and two columns (the row number is not counted at the moment). How can we do this if we want to swap the rows and columns? Prepare test data: CREATETABLETempSum (nINT, genderVARCHAR (10), totalINT);
Take three sites and three parameters as an example. 1. When the parameter column is selected, selectzad_time, zad_sid, zad_data1, zad_data2, zad_data3, zad_data4from [XHAQMMS_CDB]. [dbo]. [XHZ_T_DAYREP_AQI_XZ] wherezad_sidin (000002,) andzad_time201
SQL column/column conversion problem table structure
ID KEY VAL
1 sex male
2 day 365
4 num 12345
Now I want to display male echo $ a ['sex'] on this page. male echo $ a ['day'] will display 365.
How can I easily write mysql statements for PHP
-- Create a test environment
Create Table (year varchar (10), name varchar (10), value varchar (10 ))
-- Insert data
Insert into table
Select '200', 'A', '1' union
Select '200', 'B', '4' union
Select '200', 'C', '5' union
Select '200', 'A', '7'
For a simple table, there are two rows and two columns (the row number is not counted at the moment). How can we do this if we want to swap the rows and columns?
Prepare test data first:
Create Table Tempsum (n Int , Gender Varchar ( 10 ),
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.