sponsor

Slider

صور المظاهر بواسطة kelvinjay. يتم التشغيل بواسطة Blogger.

Comment

Ad Banner

Sports

Recent News

بحث هذه المدونة الإلكترونية

Blog Archive

بحث هذه المدونة الإلكترونية

Post Top Ad

Your Ad Spot

Facebook

Subscribe Us

Slider

Ad Code

Responsive Advertisement

About Us

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an... more →

المساهمون

Send Quick Message

الاسم

بريد إلكتروني *

رسالة *

Discovering Evergreen Bangladesh Intemacy

Discovering Evergreen Bangladesh Intemacy
.................................

Thumbnail Image

Thumbnail Image

Breaking

Find me! @ cofkhan.ml

test

Recent Tube

» » Tips & Tricks MS Access Row Number in a Query

Tips & Tricks

New Tips Added Weekly!
Click here to get on our Mailing List

  
 
MS Access

Row Number in a Query

Adding a Row Number in your Query.

In this tutorial you will learn how to add a ROW number to a Query.

Take an example Table of some Names.

tblNames
IDFirstName
1Fred
3Barry
4Joan
5Ben
7Will

You wish to add the Row number beside them:

tblNames
Row #IDFirstName
11Fred
23Barry
34Joan
45Ben
57Will

There is no row_number like in SQL Server.

You can achive this in a number of ways:

1
2
RowNum: DCount("[ID]","[tblNames]","[ID]<=" & [ID])

See this FREE Tip on DCOUNT.

1
2
3
4
5
SELECT A.*,
    (SELECT COUNT(*) FROM tblNames WHERE A.ID>=ID) AS RowNum
FROM tblNames AS A
ORDER BY A.ID;

These are not very efficient so don't use them on large recordsets.

An addition to this could be adding the Ordinal or Suffix of stndrd or th

Just create a Function:

1
2
3
4
5
6
7
8
9
10
11
Function myOrdinal (D as Integer) as String
    Dim Suffix as String
    Select Case D
        Case 1, 21, 31: Suffix = "st"
        Case 2, 22: Suffix = "nd"
        Case 3, 23: Suffix = "rd"
        Case Else: Suffix = "th"
    End Select
    myOrdinal = D & Suffix
End Function

First shown at Forum.

 

Courtusy: Alex Hedley (Avatar) By: Alex Hedley



 

You may want to read these articles from the 599CD News:

 

«
Next
رسالة أحدث
»
Previous
رسالة أقدم

ليست هناك تعليقات:

Leave a Reply