One of the values in the MySQL database is in the first row of the item, and it's a few hundred minutes.

Source: Internet
Author: User
Tags rowcount

SQL is as follows:

SQL 1.

SELECTX.user_id, X.total_no, X.order_no, X.order_no/X.total_no asPercentage_no from(SELECT @rowNum:= @rowNum + 1  asOrder_no,@rowCount  asTotal_no,user_id     fromT_sd_user, (SELECT @rowNum:= 0) b, (SELECT @rowCount:= (                SELECT COUNT(*)                 fromT_sd_user)) CORDER  by user_id DESC) XWHERE user_id = 3008

Sql2.

SELECTx.comment_id, X.total_no, Order_no, Ifnull (x.order_no/X.total_no,1) asPercentage_no from(SELECT @rowNum:= @rowNum + 1  asOrder_no,@rowCount  astotal_no, t.comment_id, t.comment_spending fromT_sd_comment T, (SELECT @rowNum:= 0) b, (SELECT @rowCount:= (                SELECT COUNT(*)                 fromt_sd_commentWHERETo_days (Create_time)>=To_days (now ()))) CORDER  byCreate_timeDESC) XWHEREcomment_id=  the

Related Article

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.