Jyske Bank er rykket ind i Glaskuben på Kalvebod Brygge, et markant byggeri i hjertet af København. Knap 1.000 arbejder her, heraf 200 i IT, med nye rammer for samarbejde, innovation og udvikling.
WHERE are you using the result? If you make a view then this will give you the SQL you need, and this can be used in your program! What program are you using?
I'm writing a Delphi application, and are using the Tdbgrid to view the results.
I am used to work with db engines which support calculated fields in this manner, so I assumed it would be possible in SQL also..
By the way, if i make a select statement like i proposed in my original question, the result will only return accounts which has posts in it.. I don't understand why.. can you help here?
My actual SQL query looks like this:
SELECT t_finanskonto.Nr, t_finanskonto.Navn, t_finanskonto.Beskrivelse, t_finanskonto.Startdato, t_finanskonto.Slutdato, t_finanskonto.Type, t_finanskonto.Sumfra, t_finanskonto.Sumtil, t_finanskonto.Spaerret, SUM(t_finanspost.beloeb) AS balance FROM t_finanskonto INNER JOIN t_finanspost ON t_finanskonto.Nr = t_finanspost.kontonr GROUP BY t_finanskonto.Nr, t_finanskonto.Navn, t_finanskonto.Beskrivelse, t_finanskonto.Startdato, t_finanskonto.Slutdato, t_finanskonto.Type, t_finanskonto.Sumfra, t_finanskonto.Sumtil, t_finanskonto.Spaerret
Just to make sure I understand where we are, does this SQL work appart from the fact that it only returns accounts with "posts" in it? If so then you problem is more than likley this part
INNER JOIN t_finanspost ON t_finanskonto.Nr = t_finanspost.kontonr
INNER JOIN means that it will only select records where there are matching records in both tables. You need to make this to an OUTER JOIN but this can be a LEFT OUTER or RIGHT OUTER. The easiest way to do this is in the Design View window. You will have two tables with a line (realtionship) between them. Right click on the line and you should see two lines Select All Rows from .... choose the one which best suits your needs. This will make the correct outer join for you. But It may also give other problems! SUM() will maybe fail because there are no values to sum up!
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.