MySQL grouping sort

Source: Internet
Author: User

http://blog.csdn.net/isoleo/article/details/50817976

1, add line number, B table has no substantive effect, just add line number , (Add a column ) an operation

Select @r:= @r+1 as Row_no, pkgname, coefficient, model_id
From A,
(select @r:=0) b
Limit 10;

2, generate the group ordinal, MySQL no row_number (), partition function function, the following statements are grouped according to MODEL_ID,

Select

@group_row: = Case When @model_id =a.model_id Then @group_row +1 Else 1 end as Group_row,

@model_id:=a.model_id as model_id,
A.coefficient,a.pkgname

From ' Getui_tag '. ' Model_coefficient ' A,

(Select @group_row: =1, @model_id: = ") b

Limit 100;

MySQL grouping sort

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.