Jeg er lidt rundtosset af hentning af data i en måned. Jeg vil lave et udtræk fra min Access database, hvor jeg vil loope igennem et år, og for hvert år trækker jeg SUM(tal) af alle database rækkerne i den givne måned.
Date = Dato og klokkeslæt Term, Trs, Trf = tal
Her er koden so far..
Dim CurrentDate, NextDate As Date Dim sSQL As String = ""
sSQL = "SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE Date BETWEEN #" & CurrentDate & "# AND #" & NextDate & "#"
Den vil bare ikke hente rigtig data ud. Hvad gøre jeg forkert ?
Der kommer nogen data (forkert) ud for nogle måneder, og ingen for andre.... Jeg får ingen fejlmelding, ok det kan være fordi jeg har try catch statement omkring sql sætningen...
I øjeblikket ser dn sådan ud: SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #01/01-2005# AND #01/02-2005# SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #01/02-2005# AND #01/03-2005# SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #01/03-2005# AND #01/04-2005# SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #01/04-2005# AND #01/05-2005# SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #01/05-2005# AND #01/06-2005# SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #01/06-2005# AND #01/07-2005# SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #01/07-2005# AND #01/08-2005# SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #01/08-2005# AND #01/09-2005# SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #01/09-2005# AND #01/10-2005# SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #01/10-2005# AND #01/11-2005# SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #01/11-2005# AND #01/12-2005# SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #01/12-2005# AND #01/01-2006#
Denne her giver nogenlunde samme resultat. SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #01/01-2004# AND #02/01-2004# SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #02/01-2004# AND #03/01-2004# SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #03/01-2004# AND #04/01-2004# SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #04/01-2004# AND #05/01-2004# SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #05/01-2004# AND #06/01-2004# SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #06/01-2004# AND #07/01-2004# SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #07/01-2004# AND #08/01-2004# SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #08/01-2004# AND #09/01-2004# SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #09/01-2004# AND #10/01-2004# SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #10/01-2004# AND #11/01-2004# SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #11/01-2004# AND #12/01-2004# SELECT SUM(Term+Trs+Trf),SUM(Term),SUM(Trs),SUM(Trf),SUM(Inf) FROM tblFlyvning WHERE [Date] BETWEEN #12/01-2004# AND #01/01-2005#
Synes godt om
Ny brugerNybegynder
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.