Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread SELECT MAX - HOW?
Fri, Apr 28 2006 1:44 PMPermanent Link

"TorB."
Hi experts Smile

I have this very simple query:
SELECT MAX(Nr)
INTO NFAKT
FROM FAKTURA

It works OK, but if the FAKTURA table is empty a NULL value is put into the
NFAKT table.
How can I change the SQL and put 0 (The number Zero) into NFAKT if the
FAKTURA table is empty?
I have tried with a varity of IF-statements of which none have worked.

Kind regards
TorB.

Fri, Apr 28 2006 2:02 PMPermanent Link

"Jose Eduardo Helminsky"
TorB

Try using this (not tested)
select if(max(nr)=null,0,max(nr)) from faktura

Eduardo

Fri, Apr 28 2006 2:18 PMPermanent Link

"TorB."
Hi Eduardo!

My God Smile
I got an answer in 16 mins, I am impressed.

Your solution worked like this:
SELECT
IF(MAX(NR)=NULL,0,MAX(NR))
INTO NFAKT
FROM FAKTURA

Thank you very much for your kind help.

Best regards
TorB.

***
"Jose Eduardo Helminsky" <contato@hpro.com.br> skrev i melding
news:38B95F31-D0A1-4EB5-AF81-F3B681AC838D@news.elevatesoft.com...
> TorB
>
> Try using this (not tested)
> select if(max(nr)=null,0,max(nr)) from faktura
>
> Eduardo
>

Fri, Apr 28 2006 2:54 PMPermanent Link

"Jose Eduardo Helminsky"
TorB

You are welcome.

Eduardo

Fri, Apr 28 2006 3:38 PMPermanent Link

"Clive"
OR.. If you wanted another way!.. Every so slightly shorter, but same
result.

SELECT
Coalesce(MAX(NR),0)
INTO NFAKT
FROM FAKTURA



"TorB." <newspost@datarommet.no> wrote in message
news:225E9356-AA5B-4592-A1A2-B4DDF84ADFA0@news.elevatesoft.com...
> Hi Eduardo!
>
> My God Smile
> I got an answer in 16 mins, I am impressed.
>
> Your solution worked like this:
> SELECT
> IF(MAX(NR)=NULL,0,MAX(NR))
> INTO NFAKT
> FROM FAKTURA
>
> Thank you very much for your kind help.
>
> Best regards
> TorB.
>
> ***
> "Jose Eduardo Helminsky" <contato@hpro.com.br> skrev i melding
> news:38B95F31-D0A1-4EB5-AF81-F3B681AC838D@news.elevatesoft.com...
>> TorB
>>
>> Try using this (not tested)
>> select if(max(nr)=null,0,max(nr)) from faktura
>>
>> Eduardo
>>
>
>

Fri, Apr 28 2006 8:08 PMPermanent Link

"TorB."
Thank you, Clive!
I'll check it up.
Best regards
TorB.
****
"Clive" <dd@dddd.com> skrev i melding
news:4276C24E-4D0D-4E77-9649-38CDFEC6981D@news.elevatesoft.com...
> OR.. If you wanted another way!.. Every so slightly shorter, but same
> result.
>
> SELECT
> Coalesce(MAX(NR),0)
> INTO NFAKT
> FROM FAKTURA
>
>
>
> "TorB." <newspost@datarommet.no> wrote in message
> news:225E9356-AA5B-4592-A1A2-B4DDF84ADFA0@news.elevatesoft.com...
>> Hi Eduardo!
>>
>> My God Smile
>> I got an answer in 16 mins, I am impressed.
>>
>> Your solution worked like this:
>> SELECT
>> IF(MAX(NR)=NULL,0,MAX(NR))
>> INTO NFAKT
>> FROM FAKTURA
>>
>> Thank you very much for your kind help.
>>
>> Best regards
>> TorB.
>>
>> ***
>> "Jose Eduardo Helminsky" <contato@hpro.com.br> skrev i melding
>> news:38B95F31-D0A1-4EB5-AF81-F3B681AC838D@news.elevatesoft.com...
>>> TorB
>>>
>>> Try using this (not tested)
>>> select if(max(nr)=null,0,max(nr)) from faktura
>>>
>>> Eduardo
>>>
>>
>>
>
>

Image