Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 15 total
Thread SQL Please help
Wed, Jul 9 2008 8:27 AMPermanent Link

Dieter Nagy
Hello

when I use this:

Select zahl,count(zahl) AS Anzahl,
      max(runde)AS Letzte_Runde,max(runde)
      -(select max(runde) from ZAHLEN) AS Differenz
      FROM total
      group by zahl

then I get

1  3   ...........
2  2   ...........
4  2   ...........        <==== 3 is missing, that is correct
5  2   ...........
.....

when I use this:

Select zahl,count(zahl) AS Anzahl,
      max(runde)AS Letzte_Runde,max(runde)
      -(select max(runde) from ZAHLEN) AS Differenz
      FROM zahl
      left join total                        <======
      on zahl.zahl = total.zahl
      group by zahl

then I get this:

1  3 .........
2  2 .........
3  1 .........          <===== that is not correct!
4  2 .........
5  2 .........
.......

anything in the second SQL ist wrong, but what?

Please help
Dieter
Wed, Jul 9 2008 9:08 AMPermanent Link

Heiko Knuettel
Dieter,

you have different tables in the FROM clause (total and zahl)...depending on the data in
that tables, the results of each query could be different.
Sure you don't want the 2nd query to be "FROM total LEFT JOIN zahl" ?

Heiko
Wed, Jul 9 2008 9:32 AMPermanent Link

Dieter Nagy
Heiko,

no, the table zahl is a table from 1............
I cannot change the left join

Dieter







Heiko Knuettel <heiko@knuettel.com> wrote:

Dieter,

you have different tables in the FROM clause (total and zahl)...depending on the data in
that tables, the results of each query could be different.
Sure you don't want the 2nd query to be "FROM total LEFT JOIN zahl" ?

Heiko
Wed, Jul 9 2008 1:27 PMPermanent Link

"John Hay"
Diete

>
> Select zahl,count(zahl) AS Anzahl,
>        max(runde)AS Letzte_Runde,max(runde)
>        -(select max(runde) from ZAHLEN) AS Differenz
>        FROM total
>        group by zahl

> 2  2   ...........
> 4  2   ...........        <==== 3 is missing, that is correct
> 5  2   ...........
> ....
>
> when I use this:
>
> Select zahl,count(zahl) AS Anzahl,
>        max(runde)AS Letzte_Runde,max(runde)
>        -(select max(runde) from ZAHLEN) AS Differenz
>        FROM zahl
>        left join total                        <======
>        on zahl.zahl = total.zahl
>        group by zahl
>
> then I get this:
>
> 1  3 .........
> 2  2 .........
> 3  1 .........          <===== that is not correct!
> 4  2 .........
> 5  2 .........

You should be getting

3  Null

Do youi have a small set of tables which shows this?  I tried it here and I
get a null if there are no records in the "total" table.

John


Wed, Jul 9 2008 1:58 PMPermanent Link

Dieter Nagy
John,

sure, where should I upload the tables?

Dieter





"John Hay" <j.haywithoutdot@crbsolutionsremoveallthis.co.uk> wrote:

Diete

>
> Select zahl,count(zahl) AS Anzahl,
>        max(runde)AS Letzte_Runde,max(runde)
>        -(select max(runde) from ZAHLEN) AS Differenz
>        FROM total
>        group by zahl

> 2  2   ...........
> 4  2   ...........        <==== 3 is missing, that is correct
> 5  2   ...........
> ....
>
> when I use this:
>
> Select zahl,count(zahl) AS Anzahl,
>        max(runde)AS Letzte_Runde,max(runde)
>        -(select max(runde) from ZAHLEN) AS Differenz
>        FROM zahl
>        left join total                        <======
>        on zahl.zahl = total.zahl
>        group by zahl
>
> then I get this:
>
> 1  3 .........
> 2  2 .........
> 3  1 .........          <===== that is not correct!
> 4  2 .........
> 5  2 .........

You should be getting

3  Null

Do youi have a small set of tables which shows this?  I tried it here and I
get a null if there are no records in the "total" table.

John
Wed, Jul 9 2008 2:50 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Dieter,

<< sure, where should I upload the tables? >>

If they can be put in a public place, then the Binaries newsgroup here will
be fine.  I'd like to take a look at this also.

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Jul 9 2008 4:23 PMPermanent Link

Dieter Nagy
Tim,

sorry I tried it to send two times, but I cant.


Dieter






"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote:

Dieter,

<< sure, where should I upload the tables? >>

If they can be put in a public place, then the Binaries newsgroup here will
be fine.  I'd like to take a look at this also.

--
Tim Young
Elevate Software
www.elevatesoft.com
Wed, Jul 9 2008 6:27 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Dieter,

<< sorry I tried it to send two times, but I cant. >>

Did you try to email it to me, or did you try to post in the Binaries
newsgroup ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Thu, Jul 10 2008 2:10 AMPermanent Link

Dieter Nagy
Tim,

I sent it to the binaries. At this time I tried it once again, but I can't.

I send it now to <timyoung@elevatesoft.com>.

TIA
Dieter







"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote:

Dieter,

<< sorry I tried it to send two times, but I cant. >>

Did you try to email it to me, or did you try to post in the Binaries
newsgroup ?

--
Tim Young
Elevate Software
www.elevatesoft.com
Thu, Jul 10 2008 3:52 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Dieter,

<< I sent it to the binaries. At this time I tried it once again, but I
can't.

I send it now to <timyoung@elevatesoft.com>. >>

Hmm, using your data and 2.00, I get the correct results also - a NULL for
the third row/second column value.

--
Tim Young
Elevate Software
www.elevatesoft.com

Page 1 of 2Next Page »
Jump to Page:  1 2
Image