Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread How used a null value in select field with union
Wed, Jun 10 2009 9:06 AMPermanent Link

Eric Derrien
my query :
Select
 D.ID, D.Client, D.NoFact, D.DateFact, D.Values, Sum(D.TTC_Montant) As Ttc, Sum(R.MtRegle) As Regler, Sum(D.TTC_Montant - R.MtRegle) As Solde

From
 Documents D
   Left Outer Join Reglement R On R.Document = D.ID

Where
 Removed    = 0 And
 FastFilter = 5

Group By
 D.ID, D.Client

Union All

Select
 -1, -1, '', Min(DateFact), Min(D.Values), Sum(D.TTC_Montant), Sum(R.MtRegle), Sum(D.TTC_Montant - R.MtRegle)

From
 Documents D
   Left Outer Join Reglement R On R.Document = D.ID

Where
 Removed    = 0 And
 FastFilter = 5

Order By
6


I have a problem with second select, D.Values is a memo field and D.DateFact is a date field
With the SQL engine as DB2, SQL Server, Oracle, I used to put NULL in place of the fields (D.DateFact And D.Values) not required
like this Select  -1, -1, '', Null, Null, Sum(D.TTC_Montant), Sum(R.MtRegle), Sum(D.TTC_Montant - R.MtRegle)

For resolve this problem I put the function Min () for the date field but this does not works on the Memo field

how can I do?
Wed, Jun 10 2009 11:21 AMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Eric,

NULL values have no type, so you must cast them so that DBISAM can match the
types of the corresponding columns:

....
UNION ALL
SELECT
  -1, -1, '', CAST(NULL AS DATE), CAST(NULL AS MEMO), Sum(D.TTC_Montant),
Sum(R.MtRegle), Sum(D.TTC_Montant - R.MtRegle)
....


--
Fernando Dias
[Team Elevate]
Wed, Jun 10 2009 11:31 AMPermanent Link

Eric Derrien
Perfect

Thanks
Image