A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

numbering row in a table by group



 
 
Thread Tools Display Modes
  #1  
Old August 7th, 2004, 11:02 AM
PF
external usenet poster
 
Posts: n/a
Default numbering row in a table by group

Hi,

i am using access and i want to rank my table by group of product
tblProd and i want

a,... a,1
b,... b,1
b,... b,2
c,... c,1
c,... c,2
c,... c,3

Where the count is reset each time the product change

if i use
SELECT tblProd.PRODUIT, (select count (*) from tblProd t1 where t1.produit
t.produit or (t1.produit = t.produit)) AS nb
FROM tblProd

This is not working. Acess dont recognize T1.
I supopose that it works in sql server or other.

Any advise?
regards





  #2  
Old August 7th, 2004, 02:12 PM
Brian Camire
external usenet poster
 
Posts: n/a
Default numbering row in a table by group

There are three problems with your original query:

1. Access did not recognize the table alias "t" used in the subquery.

2. It would not "reset" the count.

3. You need at least one other field (or combination of fields) by which to
"rank" records, preferably uniquely.

Assuming you have such a field (it might typically be an AutoNumber field or
primary key, a Date/Time field, or some field specific to the kind of data
you're dealing with) and it is named "Your Other Field", you might try
something like this:

SELECT
t.PRODUIT,
(SELECT
Count (*)
FROM tblProd AS t1
WHERE
t1.PRODUIT = t.PRODUIT
AND
t1.[Your Other Field] = t.[Your Other Field]) AS nb
FROM tblProd AS t


"PF" wrote in message
. ..
Hi,

i am using access and i want to rank my table by group of product
tblProd and i want

a,... a,1
b,... b,1
b,... b,2
c,... c,1
c,... c,2
c,... c,3

Where the count is reset each time the product change

if i use
SELECT tblProd.PRODUIT, (select count (*) from tblProd t1 where

t1.produit
t.produit or (t1.produit = t.produit)) AS nb
FROM tblProd

This is not working. Acess dont recognize T1.
I supopose that it works in sql server or other.

Any advise?
regards







  #3  
Old August 7th, 2004, 09:04 PM
PF
external usenet poster
 
Posts: n/a
Default numbering row in a table by group

thanks

pf

"Brian Camire" a écrit dans le message de
...
There are three problems with your original query:

1. Access did not recognize the table alias "t" used in the subquery.

2. It would not "reset" the count.

3. You need at least one other field (or combination of fields) by which

to
"rank" records, preferably uniquely.

Assuming you have such a field (it might typically be an AutoNumber field

or
primary key, a Date/Time field, or some field specific to the kind of data
you're dealing with) and it is named "Your Other Field", you might try
something like this:

SELECT
t.PRODUIT,
(SELECT
Count (*)
FROM tblProd AS t1
WHERE
t1.PRODUIT = t.PRODUIT
AND
t1.[Your Other Field] = t.[Your Other Field]) AS nb
FROM tblProd AS t


"PF" wrote in message
. ..
Hi,

i am using access and i want to rank my table by group of product
tblProd and i want

a,... a,1
b,... b,1
b,... b,2
c,... c,1
c,... c,2
c,... c,3

Where the count is reset each time the product change

if i use
SELECT tblProd.PRODUIT, (select count (*) from tblProd t1 where

t1.produit
t.produit or (t1.produit = t.produit)) AS nb
FROM tblProd

This is not working. Acess dont recognize T1.
I supopose that it works in sql server or other.

Any advise?
regards









  #4  
Old August 11th, 2004, 02:14 PM
PF
external usenet poster
 
Posts: n/a
Default numbering row in a table by group

it works

thanks

"Brian Camire" a écrit dans le message de
...
There are three problems with your original query:

1. Access did not recognize the table alias "t" used in the subquery.

2. It would not "reset" the count.

3. You need at least one other field (or combination of fields) by which

to
"rank" records, preferably uniquely.

Assuming you have such a field (it might typically be an AutoNumber field

or
primary key, a Date/Time field, or some field specific to the kind of data
you're dealing with) and it is named "Your Other Field", you might try
something like this:

SELECT
t.PRODUIT,
(SELECT
Count (*)
FROM tblProd AS t1
WHERE
t1.PRODUIT = t.PRODUIT
AND
t1.[Your Other Field] = t.[Your Other Field]) AS nb
FROM tblProd AS t


"PF" wrote in message
. ..
Hi,

i am using access and i want to rank my table by group of product
tblProd and i want

a,... a,1
b,... b,1
b,... b,2
c,... c,1
c,... c,2
c,... c,3

Where the count is reset each time the product change

if i use
SELECT tblProd.PRODUIT, (select count (*) from tblProd t1 where

t1.produit
t.produit or (t1.produit = t.produit)) AS nb
FROM tblProd

This is not working. Acess dont recognize T1.
I supopose that it works in sql server or other.

Any advise?
regards










 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Group By Running & Setting Up Queries 3 August 5th, 2004 10:37 PM
Complicated Databse w/many relationships Søren Database Design 7 July 13th, 2004 05:41 AM
Pivot Table Error: Cannot group that selection General Discussion 4 July 2nd, 2004 04:07 PM
Group page numbering Leslie Isaacs Setting Up & Running Reports 4 May 28th, 2004 12:58 PM


All times are GMT +1. The time now is 06:33 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.