SQL to add ordinal to query result

Source: Internet
Author: User

Situation: When programming with Delphi7, want to give the result of the query a number, for example, there are 10,000 results, the initiative from 1 to 10000

The data is displayed with the DBGrid control, but its first column is not very good to display the number, find a lot of methods can not be desired

After choosing Stringgrid, the first column shows the serial number, the effect reached, but there is no dbgrid speed.

Finally, it uses the method of displaying the query result number after the query is still using DBGrid.

Method: 1. DBGrid new Add a Field,field name as ID, this field does not exist in your table.

2.SQL. Add (' SELECT ID = Row_number () over (order by time), time, a,b,c,d,e from weight WHERE year (time) =2014 ');

Show:



SQL to add ordinal to query result

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.