SQL Strings kleine Unterschiede --grosse Wirkung ??
- From: "Thomas Willms" <th.willms@xxxxxxxxxx>
- Date: 3 Dec 2007 07:23:02 -0700
Hello,
Although I tested these strings in ACCESS without using delphi I would like to ask if someone understands why these two apparently similar strings give very different results:
I have three tables:
first table: "Elements" with all chemical elements and the atomic masses (here approximately) eg.
symbol Elementname MolarMass
Na sodium 23 (u)
Cl chlor 35 (u)
second table : "PConComposition" contains the elemental composition of a chemical compound, with three fields :
field 0.name "PCon" (Phase constituent) contains name of compound eg CompNaCl
field 1.name: "Element" contains symbol of Element
field 2.name: "NumberOfElement" contains number of Elementatoms
in this case 2 etries:
"PCon" "Element" "NumberOfElement"
CompNaCl Na 1
CompNaCl Cl 1
third table: "Reactions" contains three fields and contains the formation reaction : Na + Cl --> NaCl
(here name of NaCl is "CompNaCl") as a table :
PConProduct PConReactant Coefficient
CompNaCl NaCl 1 (remark : built up by reaction)
CompNaCl Na -1 (consumed by reaction)
CompNaCl Cl -1 (consumed by reaction)
this means Na + Cl --> NaCl (mathematically: NaCl - Na -Cl = 0)
gives zero as it should :
SELECT sum(C.Coefficient * D.Molmasse) AS Bilanz
FROM public_Reactions AS C INNER JOIN (SELECT PCon, sum(A.MolarMass*B.NumberOfElement) AS Molmasse
FROM public_Element AS A INNER JOIN public_PConComposition AS B ON A.symbol=B.Element
GROUP BY B.Pcon) AS D ON D.PCon = C.PConReactant
GROUP BY PConProduct
but this string gives 116 !
SELECT sum(D.Molmasse*C.coefficient) AS GesamtBilanz
FROM public_Reactions AS C
INNER JOIN [SELECT sum(A.MolarMass*B.NumberOfElement) AS [Molmasse]FROM public_Element AS A INNER JOIN public_PConComposition AS B ON B.Element = A.symbol group by B.PCon]. AS D
ON C.PConReactant = D.PCon
GROUP BY C.PConProduct;
Anyone any idea how this is possible ?
Thomas Willms
.
- Prev by Date: Re: MS SQL 2000, ADO and edit lock
- Next by Date: Re: MS SQL 2000, ADO and edit lock
- Previous by thread: provider cannot derive parameter information
- Next by thread: sorry once more in english: sql : little differences big effects ??
- Index(es):
Relevant Pages
|