Avatar billede cms2 Nybegynder
02. juli 2003 - 18:12 Der er 15 kommentarer og
1 løsning

Tælle dato indførsler i en forespørgsel.

Hej
Har en forespørgsel over hvor der optræder dato.
Har brug for en sammentælling af poster hvor dato er indført, altså forskellig fra "blank"
Avatar billede terry Ekspert
02. juli 2003 - 18:18 #1
SELECT count(*) FROM Your Table where NOT (DatoField) Is Null
02. juli 2003 - 19:04 #2
eller:
SELECT count(*) FROM Your Table where DatoField) Is Not Null
02. juli 2003 - 19:04 #3
SELECT count(*) FROM Your Table where DatoField Is Not Null
Avatar billede terry Ekspert
03. juli 2003 - 12:02 #4
cms2>We cant help if you dont comment!
Avatar billede cms2 Nybegynder
03. juli 2003 - 19:07 #5
Sorry Terry, was not at my PC, thanks it worked fine
Avatar billede terry Ekspert
04. juli 2003 - 09:21 #6
your welcome :o)
Avatar billede cms2 Nybegynder
08. juli 2003 - 10:33 #7
Hej igen
Var lige en anelse for hurtig.
Ovennævnte tæller "dato is not null" i tabellen, men jeg skal kun bruge
de poster som forespørgslen har udvalgt
Avatar billede terry Ekspert
08. juli 2003 - 17:39 #8
SELECT * FROM Your Table where NOT (DatoField) Is Null
Avatar billede cms2 Nybegynder
09. juli 2003 - 11:27 #9
That dos not work Terry, do you have an e-mail, maybe easier if you see
my amateur work
Avatar billede terry Ekspert
09. juli 2003 - 17:29 #10
eksperten@santhell.dk
Avatar billede terry Ekspert
09. juli 2003 - 20:24 #11
Hi Claus, well it wasnt what I was expecting, but none the less! I hope this is what you are after. The query selects the records using the criteria from your form. So I am assuming that it also needs to count those with the same criteria where the date has been entered. If thats the case then the criteria are needed in the count too.

SELECT Hull.HullNumber, MainArea.Department, MainArea.MainArea, Description.Description, Hull_Description.TypeID, Hull_Description.Date1, Hull_Description.TypeID2, Hull_Description.date2, Hull_Description.TypeID3, Hull_Description.date3, Hull_Description.Protocol, Hull_Description.Remarks, (SELECT Count(Hull_Description.Date1) AS CountOfDate1 FROM Hull INNER JOIN ((MainArea INNER JOIN Description ON MainArea.MainID = Description.MainID) INNER JOIN Hull_Description ON Description.ID = Hull_Description.Des) ON Hull.HullId = Hull_Description.HullId GROUP BY Hull.HullNumber, MainArea.Department, MainArea.MainArea HAVING (((Hull.HullNumber) Like [Forms]![Menu]![findhull]) AND ((MainArea.Department) Like [Forms]![Menu]![finddepartment]) AND ((MainArea.MainArea) Like [Forms]![Menu]![findarea]) AND (Not (Count(Hull_Description.Date1)) Is Null))) AS Expr1
FROM Hull INNER JOIN ((MainArea INNER JOIN Description ON MainArea.MainID = Description.MainID) INNER JOIN Hull_Description ON Description.ID = Hull_Description.Des) ON Hull.HullId = Hull_Description.HullId
WHERE (((Hull.HullNumber) Like [Forms]![Menu]![findhull]) AND ((MainArea.Department) Like [Forms]![Menu]![finddepartment]) AND ((MainArea.MainArea) Like [Forms]![Menu]![findarea]));
Avatar billede cms2 Nybegynder
10. juli 2003 - 11:19 #12
Terry, truely you have deserved your 60 points:-)
But for an amateur like my self, above is "too much" to handle.
I better settle to count by hand only.

Apart from that, you are right i also needed to count on the other "date fields"
Avatar billede terry Ekspert
10. juli 2003 - 18:26 #13
Claus>Cut and paste the above SQL into the query "Hull Query" an dit will give you what you had before AND the count for Date1.

Then in a new field (beside the Date1) enter

CountForDate2:(SELECT Count(Hull_Description.Date2) AS CountOfDate2 FROM Hull INNER JOIN ((MainArea INNER JOIN Description ON MainArea.MainID = Description.MainID) INNER JOIN Hull_Description ON Description.ID = Hull_Description.Des) ON Hull.HullId = Hull_Description.HullId GROUP BY Hull.HullNumber, MainArea.Department, MainArea.MainArea HAVING (((Hull.HullNumber) Like [Forms]![Menu]![findhull]) AND ((MainArea.Department) Like [Forms]![Menu]![finddepartment]) AND ((MainArea.MainArea) Like [Forms]![Menu]![findarea]) AND (Not (Count(Hull_Description.Date2)) Is Null)))

and for date3
CountForDate3:(SELECT Count(Hull_Description.Date3) AS CountOfDate3 FROM Hull INNER JOIN ((MainArea INNER JOIN Description ON MainArea.MainID = Description.MainID) INNER JOIN Hull_Description ON Description.ID = Hull_Description.Des) ON Hull.HullId = Hull_Description.HullId GROUP BY Hull.HullNumber, MainArea.Department, MainArea.MainArea HAVING (((Hull.HullNumber) Like [Forms]![Menu]![findhull]) AND ((MainArea.Department) Like [Forms]![Menu]![finddepartment]) AND ((MainArea.MainArea) Like [Forms]![Menu]![findarea]) AND (Not (Count(Hull_Description.Date3)) Is Null)))

Is that what you wanted?
Avatar billede cms2 Nybegynder
10. juli 2003 - 21:26 #14
"The text is too long to be edited" :-)
Or it might be me, that dont have the faintest
idea where to paste it
Avatar billede terry Ekspert
10. juli 2003 - 21:44 #15
I'll send it :o)
Avatar billede terry Ekspert
10. juli 2003 - 21:49 #16
can you give me your email, I have deleted the one you sent!
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester