Hai
I need some help, for the record I am new to VB and access
I have two tables (parent) and (child) . I want to count the number of children for each parent. I want to use date of birth and not ChildID. The number must be returned to table (parent) field amount
This must be very simple
9 5028
Mh!
have you ever dreaming while walking? Never!!!
You have to sleep I think.
What you are looking for is impossible!!!
I don't know what you mean by count the date of birth. You don't have to count any one field. You'll be counting records and grouping by the parent foreign key field in the child table.
I also don't know what you mean by return it to the parent table. I assume you're talking about an update query. But there's no need to do that. You shouldn't store that data in the table. It should be calculated on an as needed basis.
Also, your data structure is flawed. What happens when a child becomes a parent themself? You end up duplicating data.
NeoPa 32,556
Expert Mod 16PB Adam:
This must be very simple
It doesn't sound like you'd know to be frank.
I have to say that your design needs some serious consideration (See Rabbit's post). Anything implemented within such a scenario is unlikely to be remotely simple.
Thank you all for the feedback,
It seems that I asked for the impossible. For Mr key, I dream and walk and sleep-dream-walk ;)
Can someone explain to me (if possible) how to count the numbers of birth dates in the (child) table for each (parent)? Your hints are more than welcome
This must be very difficult :)
NeoPa 32,556
Expert Mod 16PB Adam:
This must be very difficult :)
I have to admit I enjoyed that. A real ROFL moment. I'm still not sure I can rely on your appreciation of the difficulty level, but a laugh is always a laugh. Spot on! Adam:
Can someone explain to me (if possible) how to count the numbers of birth dates in the (child) table for each (parent)?
This is more complicated than it sounds (You just knew I was going to say that didn't you?), but possibly not in the way you might think. Because the design of the database is : - Somewhat unnatural. As Rabbit mentioned you don't find humans naturally separated by parent/child relationships - rather you have humans with various attributes and various relationships to (some) other humans.
- Unexplained here. You don't provide much in the way of detail of what you're working with.
On top of that, the wording of the question is somewhat ambiguous. You say you want to count the dates, but do you mean the number of records associated with each parent? Possibly the number of different dates within that group (Such that twins would count only once).
Fundamentally, the answer would involve a GROUP BY query using the Count() function within the SELECT clause. More detail than that would rely on information we don't yet have.
Thanks NeoPa,
Hahah,
Ok I admit the data base (which I inherited) is unnatural and it is a complex problem. so m I, a complex unnatural problem.
Thanks, I'll have to figure something else out. I'm not a coding wiz (hahahah) and have no idea how to solve it but …. On one day there will be a (work around) solution.
What everyone is getting at is that you're not giving us any information in your question, and thus it's impossible to answer the question. If you can tell us what your table structure is exactly (table names, what the columns are, and how the tables are related) then we'll probably be able to give you a more focused response.
Pat
Hai zepphead80,
I have two tables (tbparent) and (tbchild).
(Tbparent) contains [parentID], [parentID] ,[fname] ,[sname]
(Tbchild) contains [childID], [fname], [Dbirth] ,[parentID]
Question
How to count the number [Dbirth] for each [parentID]?
I hope this is clear
Thanks
NeoPa 32,556
Expert Mod 16PB
I would suggest the following. It's lucky [tbparent] isn't required as it seems to have two fields with the same name. - SELECT [parentID]
-
Count([Dbirth]) AS [NumDB]
-
FROM [tbchild]
-
GROUP BY [parentID]
PS. You didn't answer the questions I posed in post #6, so the SQL still doesn't make a lot of sense (but still works in a very basic way). Technically this answers your question but it's unlikely to be perfect I suspect, because I'm guessing the question is a reflection of your confusion about what you actually want. Counting a particular field (rather than the records containing those fields) is rarely what's required. Generally the records are what need counting (in which case you'd use Count(*) instead).
Sign in to post your reply or Sign up for a free account.
Similar topics
by: PT |
last post by:
I got a problem. And thats.....
First of all, I got these three tables.
------------------- ------------------ ----------------------
tblPerson tblPersonSoftware ...
|
by: news |
last post by:
This is a tough question to ask.
I need to pull up a report of all the orders in our e-commerce site,
that has more than one item attributed to it.
orders.ordernum, orderitems.itemnumber...
|
by: sdowney717 |
last post by:
Using the the NumId from TitleData, I would like to delete the
corresponding row in Bookdata using pure SQL. I want it to delete all
rows in bookdata where the Titledata.NumID is a match to...
|
by: c.le_roq |
last post by:
Hello,
Using rollup I want to count the number of rows of a table
called Table1 which is LEFT JOINED with a table called Table2.
The problem is that we can have more than 1 rows in Table2 that...
|
by: Colm O'Hagan |
last post by:
Hi there,
I having a problem with a database I'm setting up, I would be
delighted if someone out there could help.
The database I'm setting up is a task register datebase, it will be
used to...
|
by: bill |
last post by:
I am sure there must be an easy way to determine the number of
rows in a table, but I can't find it.
I appreciate the courtesy and patience ng members have shown this
mysql novice.
bill
|
by: sherzodr |
last post by:
If anyone can help me with this problem, I'll make you my hero of the
month (preferably April 2007). I'll even pin your name above my desk
for the whole month. Oh yes I can do that!
I need to...
|
by: Margie |
last post by:
Hello all, after getting no where with my Access 2007 database problem for an entire week I figured I could use some outside help.
Wanting to skill myself in Access, I decided to make a movie...
|
by: RISHA |
last post by:
can someone please help me.i wanted to count the rows of a table for today,30 days back,90 days back and 180 days back.can someone please help me to write a code for this in sql.thanks
|
by: HaLo2FrEeEk |
last post by:
I've got a table where I store tips for a challenge. Its structure is this:
tip_id, challenge_id, user_id, ip_address, tip_date, tip_text
The tips can be voted up or down, I store vote data in...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |