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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
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 |