sql problem - how to write this in sql

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Foxie Foxster

    #1

    sql problem - how to write this in sql

    i have two tables nl tblLEV and tblPOINTS (each with a certain number of
    fields)

    now i wrote the following sql

    sqltekst= "SELECT DISTINCTROW tblLEV.LEVname, tblPOINTS.* from tblLEV inner
    join tblPOINTS ON tblLEV.levid=tb lPOINTS.pointsi d ORDER BY levpt DESC,
    levpt1 DESC


    comment: levpt en levpt are fields from table tblLEV and the ordening works
    fine

    but now the problem........ ...............

    there are numeric fields in tblPOITS points1, points2 and I want to complete
    the order with

    sum(points1) DESC, sum(points2) DESC


    questions:
    in qsl is summating sum(points)????
    if not how is it done????

    can anyone understand what i'm saying or give me some advice???

    thx and greetigns


  • DFS

    #2
    Re: sql problem - how to write this in sql

    I think you want something like:

    SELECT L.LevName, Sum(P.Points1) as SumPoints1, Sum(P.Points2) as SumPoints2
    FROM tblLEV L INNER JOIN tblPOINTS P
    ON L.LevID = P.PointsID
    GROUP BY L.LevName
    ORDER BY Sum(P.Points1) DESC


    "Foxie Foxster" <verik.reynaert @skynet.be> wrote in message
    news:3fcf2d72$0 $2871$ba620e4c@ reader1.news.sk ynet.be...[color=blue]
    > i have two tables nl tblLEV and tblPOINTS (each with a certain number[/color]
    of[color=blue]
    > fields)
    >
    > now i wrote the following sql
    >
    > sqltekst= "SELECT DISTINCTROW tblLEV.LEVname, tblPOINTS.* from tblLEV[/color]
    inner[color=blue]
    > join tblPOINTS ON tblLEV.levid=tb lPOINTS.pointsi d ORDER BY levpt DESC,
    > levpt1 DESC
    >
    >
    > comment: levpt en levpt are fields from table tblLEV and the ordening[/color]
    works[color=blue]
    > fine
    >
    > but now the problem........ ...............
    >
    > there are numeric fields in tblPOITS points1, points2 and I want to[/color]
    complete[color=blue]
    > the order with
    >
    > sum(points1) DESC, sum(points2) DESC
    >
    >
    > questions:
    > in qsl is summating sum(points)????
    > if not how is it done????
    >
    > can anyone understand what i'm saying or give me some advice???
    >
    > thx and greetigns
    >
    >[/color]


    Comment

    • Foxie Foxster

      #3
      Re: sql problem - how to write this in sql

      thx for reply

      so in the order it is possible to calculate

      and well

      order SUM(points)

      though that doesn't work with me......

      must there be a calculation after the SELECT WORD????


      "DFS" <nospamDS@nospa m.com> schreef in bericht
      news:vsugr61eum bqd0@corp.super news.com...[color=blue]
      > I think you want something like:
      >
      > SELECT L.LevName, Sum(P.Points1) as SumPoints1, Sum(P.Points2) as[/color]
      SumPoints2[color=blue]
      > FROM tblLEV L INNER JOIN tblPOINTS P
      > ON L.LevID = P.PointsID
      > GROUP BY L.LevName
      > ORDER BY Sum(P.Points1) DESC
      >
      >
      > "Foxie Foxster" <verik.reynaert @skynet.be> wrote in message
      > news:3fcf2d72$0 $2871$ba620e4c@ reader1.news.sk ynet.be...[color=green]
      > > i have two tables nl tblLEV and tblPOINTS (each with a certain number[/color]
      > of[color=green]
      > > fields)
      > >
      > > now i wrote the following sql
      > >
      > > sqltekst= "SELECT DISTINCTROW tblLEV.LEVname, tblPOINTS.* from tblLEV[/color]
      > inner[color=green]
      > > join tblPOINTS ON tblLEV.levid=tb lPOINTS.pointsi d ORDER BY levpt DESC,
      > > levpt1 DESC
      > >
      > >
      > > comment: levpt en levpt are fields from table tblLEV and the ordening[/color]
      > works[color=green]
      > > fine
      > >
      > > but now the problem........ ...............
      > >
      > > there are numeric fields in tblPOITS points1, points2 and I want to[/color]
      > complete[color=green]
      > > the order with
      > >
      > > sum(points1) DESC, sum(points2) DESC
      > >
      > >
      > > questions:
      > > in qsl is summating sum(points)????
      > > if not how is it done????
      > >
      > > can anyone understand what i'm saying or give me some advice???
      > >
      > > thx and greetigns
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • DFS

        #4
        Re: sql problem - how to write this in sql

        Foxie,

        Sorry, but I'm having a hard time understanding what you're asking. Did
        that query I wrote not work? What happened? What results do you want to
        see?

        Post your table structures and maybe it'll be more clear.




        "Foxie Foxster" <verik.reynaert @skynet.be> wrote in message
        news:3fcf69d8$0 $279$ba620e4c@r eader4.news.sky net.be...[color=blue]
        > thx for reply
        >
        > so in the order it is possible to calculate
        >
        > and well
        >
        > order SUM(points)
        >
        > though that doesn't work with me......
        >
        > must there be a calculation after the SELECT WORD????
        >
        >
        > "DFS" <nospamDS@nospa m.com> schreef in bericht
        > news:vsugr61eum bqd0@corp.super news.com...[color=green]
        > > I think you want something like:
        > >
        > > SELECT L.LevName, Sum(P.Points1) as SumPoints1, Sum(P.Points2) as[/color]
        > SumPoints2[color=green]
        > > FROM tblLEV L INNER JOIN tblPOINTS P
        > > ON L.LevID = P.PointsID
        > > GROUP BY L.LevName
        > > ORDER BY Sum(P.Points1) DESC
        > >
        > >
        > > "Foxie Foxster" <verik.reynaert @skynet.be> wrote in message
        > > news:3fcf2d72$0 $2871$ba620e4c@ reader1.news.sk ynet.be...[color=darkred]
        > > > i have two tables nl tblLEV and tblPOINTS (each with a certain[/color][/color][/color]
        number[color=blue][color=green]
        > > of[color=darkred]
        > > > fields)
        > > >
        > > > now i wrote the following sql
        > > >
        > > > sqltekst= "SELECT DISTINCTROW tblLEV.LEVname, tblPOINTS.* from tblLEV[/color]
        > > inner[color=darkred]
        > > > join tblPOINTS ON tblLEV.levid=tb lPOINTS.pointsi d ORDER BY levpt DESC,
        > > > levpt1 DESC
        > > >
        > > >
        > > > comment: levpt en levpt are fields from table tblLEV and the ordening[/color]
        > > works[color=darkred]
        > > > fine
        > > >
        > > > but now the problem........ ...............
        > > >
        > > > there are numeric fields in tblPOITS points1, points2 and I want to[/color]
        > > complete[color=darkred]
        > > > the order with
        > > >
        > > > sum(points1) DESC, sum(points2) DESC
        > > >
        > > >
        > > > questions:
        > > > in qsl is summating sum(points)????
        > > > if not how is it done????
        > > >
        > > > can anyone understand what i'm saying or give me some advice???
        > > >
        > > > thx and greetigns
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        Working...