For example:ID Name Value1 a pp2 a PP3 B III4 B pp5 B pp6 C pp7 C pp8 C IIIID is primary keyAsk for such a resultID Name Value1 a pp3 B III4 B pp6 C pp8 C III
Method 1
Copy Code code as follows:
Delete yourtable
where [id] not in (
SQL Server row and column conversion Pivot UnPivotPivot 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
Method 1:1. Create a temporary table and select the desired data.2, clear the original table.3, temporary table data import into the original table.4. Delete the temporary table.Mysql> select * from student;+----+------+| ID | NAME |+----+------+| 11
A: PrefaceIn some of the projects we do, we often encounter the problem of converting rows into columns, and here's a summary: convert one format to figure two. Figure 22: First insert data into the database.IF object_id('Tmark') is not NULL DROP
Method 1:1. Create a temporary table and select the desired data.2, clear the original table.3, temporary table data import into the original table.4. Delete the temporary table.Mysql> select * from student;+----+------+| ID | NAME |+----+------+| 11
Case:Id name Course name score1 Zhang San math 692 Li Si math 893 Zhang San, mathematics 69Delete redundant student information that is identical except for automatic numbers
Bytes ---------------------------------------------------------------------
Implement POSTGRESQL cross tabulationHere I will demonstrate how to implement cross-tabulation display in POSTGRESQL. As for what a cross-tabulation is, I will not talk much about it.The raw table data is as follows:
t_girl=# select * from score;
You can splice the following query results into a table:1. Select name, count (1) as num1 from table 1 group by name;2. Select name, count (1) as num2 from table 1 where exc = 0 group by name;Note: The exc data type is bit.3. Select name, count (1)
Mysql group by usage details, mysqlgroupby details
Background
Recently, when designing a database, a large amount of duplicate data has been generated due to the lack of weeks. Now you need to delete the duplicate data. The statement used is Group.
If not object_id (' Tempdb. #T ') is nulldrop table #TGoCreate table #T ([ID] int,[name] nvarchar (1), [Memo] nvarchar (2))Insert #TSelect 1,n ' A ', N ' A1 ' UNION ALLSelect 2,n ' A ', N ' A2 ' UNION ALLSelect 3,n ' A ', N ' A3 ' UNION ALLSelect
A friend of mine once consulted me on how to implement a multi-column into a row in Impala, in fact, the self-contained function in Impala can be implemented without custom functions.Let me start with a demo:-bash-4.1$ Impala-shellStarting Impala
MySQL Forgot password login-- user=mysql--skip-grant-tables--skip-networking & -u rootCreate DATABASE MySQLUse MySQL to enter MySQL databaseShow tables View all data sheetsMariaDB[MySQL]>show tables;+---------------------------+|Tables_in_mysql|+---
MySQL large table repeating fields How do I find it? This is a lot of people have encountered problems, below teach you a MySQL large table repeat field Query method for your reference.
There is a large table in the database, and you need to find a
1. Using Loose (Loose) index scans to implement GROUP by
What is a loose index scan implementation Group by? In fact, when MySQL fully utilizes the index scan to implement group by, it does not need to scan all index keys that meet the criteria to
Create a table that holds the ID information for the record you want to delete:
The code is as follows
Copy Code
CREATE TABLE ' Tmp_ids ' (' ID ' int (11),' Name ' char (20)) Engine=myisam;
If you want to
For example:ID Name Value1 a pp2 a PP3 B III4 B pp5 B pp6 C pp7 C pp8 C IIIID is primary keyAsk for such a resultID Name Value1 a pp3 B III4 B pp6 C pp8 C IIIMethod 1Delete yourtablewhere [id] not in (Select MAX ([id]) from yourtableGroup BY (name +
For example:ID Name Value1 a pp2 a PP3 B III4 B pp5 B pp6 C pp7 C pp8 C IIIID is primary keyAsk for such a resultID Name Value1 a pp3 B III4 B pp6 C pp8 C IIIMethod 1Delete yourtablewhere [id] not in (Select MAX ([id]) from yourtableGroup BY (name +
There are 5 Mysql aggregation functions:1, COUNT () Number of records2, max () maximum value3, min () minimum value4, AVG () average5, sum () sumAggregation functions often work with groups.1. Create a groupSelect Name, Max (age) from Stu Group by
Summary of row-to-column issues1, Row to column---1, the simplest row to column/*Question: Suppose there is a student score table (TB) as follows:Name Course ScoreZhang San language 74Zhang San Mathematics 83Zhang San Physics 93John Doe Language
Let's say a student score table (TB) is as follows:Name Course ScoreZhang San language 74Zhang San Mathematics 83Zhang San Physics 93John Doe Language 74John Doe Mathematics 84John Doe Physics 94Want to become (get the following result):Name Chinese
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.