Replicate Row_Number from SQL in Access

liammoohan

Board Regular
Joined
Jan 11, 2008
Messages
72
I am using the below VBA code in an attempt to replicate Row_Number() which can be done in SQL

This is the query I have written:

SELECT A.*, (SELECT COUNT(*) FROM tblRowNosTest WHERE A.PhoneNumber = PhoneNumber And A.ListName = ListName) AS RowNos
FROM tblRowNosTest as A
ORDER BY PhoneNumber, ListName, ContactAttempts

This is how the results are then displayed:

1665155222851.png


Column 'D' is displaying as an overall count; what I am trying to get to is that I want it to show as below (see column 'E'):

1665155344802.png


Any help would be greatly appreciated in being able to get the query to output the results to look like the values in column 'E' as oppose to what it is actually outputting in column 'D' highlighted yellow.

Thanks
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
something like post 5 here?
 
Upvote 0

Forum statistics

Threads
1,214,634
Messages
6,120,659
Members
448,975
Latest member
sweeberry

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top