Problem
Calculate the number of months or years of difference between two dates. For example, calculate the number of months for the first employee and the last employee, and the number of years for these months.
Solution
Because there are 12 months
1. Select * from EMP;
2. Select Empno, ename, job from EMP;
3. Select empno number, ename name, job work from EMP;
4. Select Job from EMP;
5. Select distinct job from EMP;
6. Select distinct empno, job from EMP;Note: Because the employee number
--Go to re-query method one: based on IDSELECT * from Sxe where ID in (the Select min (id) from SXE Group by username) Order by ID ASC;--Go to re-query method two: according to RowNumSELECT * FROM (select S.*,rownum rn from SXE s) x where X.rn in
The day before yesterday, I needed to randomly extract several records from a database with 5 million records because of my work. Here I directly use the mysql rand by function. It doesn't matter if there are thousands of records, however, if tens
1. During the interview, I encountered a problem. I wrote a table with two fields, ID and name, to query all the data with duplicate names. The column is:
Select * from Xi A where (A. username) in (select username from Xi Group by username having
Find duplicate data T-SQL in the database ========== first article ============ there are duplicate records under a field in a table, there are many ways, however, there is a method that is relatively efficient. The following statement: Select
SQL statement for querying and deleting duplicate records
1. Search for redundant duplicate records in the Table. duplicate records are determined based on a single field (ID ).
Select * from table where ID in (select ID from Table group
SELECT *From ' table ' as T1 JOIN (select ROUND (RAND () * ((select MAX (ID) from ' table ')-(select min (id) from ' table ') + (select min (i d) from ' table ') as ID) as T2WHERE t1.id >= t2.idORDER by T1.id LIMIT 1;MySQL's random extraction
Subquery 1 (subquery in WHERE), where in subquerySubquery
A subquery is a compilation of complex queries by embedding several small queries with different functions in a complete query statement, to help readers better understand the concept of
I will take a look at the simplest and commonly used method. Next I will introduce the efficient method of mysql random data. If you need it, please refer to it.
I will take a look at the simplest and commonly used method. Next I will introduce the
SQL Server randomly reads several records from a table:Example: The code is as follows:Copy code Select top 10 id, title from news order by newid () After optimizationIn MSSQL, the following method is used to randomly read more than data
During the test, it was found that a new snapshot could not be generated and the system time was October 26, but the snapshot has been generated for December 1.The workaround at this point is to delete the existing snapshot.Turn http://itlab.idcquan.
MySQL query repeating fields, and how to delete duplicate recordsMySQL, database, Database, field, serverThere is a large table in the database and you need to look for a duplicate record ID for the name in order to compare it. If you are simply
? Define subqueries? Describe the types of problems that subqueries can solve? List the types of subqueries? Write single-line and multiline subqueries? Subquery: Type, syntax, and guidelines? Single-row subquery: – Group function in a subquery –
One, part of the same field to remove duplicate data method:By grouping group by repeating field the having (*) >1 condition--"Extract the duplicate field value--" Finally, based on the uniqueness of the ID--Get the value of min or Max ID in the
Oracle large data volume query actual analysis Oracle Database: just made a 50 million data extraction, the current table is still performing the insert operation, hundreds of data entries per minute. This table is partitioned by time and by month.
Oracle DatabaseMediumCodeIt is the foundation and the most basic for database operation. The Oracle Database Code involved in the following article is very valuable for beginners, and I hope it will be helpful to everyone.
Who has the highest salary
Source: http://dotnet.mblogger.cn/zzjjmm/posts/1603.aspx
Create procedure DBO. postgetpostbypage
(@ Page int,@ Forumid int,@ Topornot int)
As/* Set nocount on */Declare @ begin int, @ end int, @ F int, @ l int, @ count int, @ top int Select @ Top =
How to delete duplicate records in a table and retain only one of them [posting 12:02:05] font size: large, medium, and small
There are several identical records in thousands of records. How can I use SQL statements to delete duplicates? Thank you!1.
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.