Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL Grouping query
    text
    copied!<p>I have a sql query that runs fine but it returns results from 2 different tables that contain a breakdown of contracts and the projects that belong to them. </p> <p>An example of this is: Contract number 12004 contains Projects 12004C, 12004D, 12004F</p> <p>is there a way I can get all 12004 to group together under the 12004 banner contract Number?</p> <p>My query as it stands to get me the current info is:</p> <pre><code>SELECT PA01201.PACONTNUMBER, PA01201.PAPROJNUMBER, PA01201.PAprojname, PA01100.PAcontname FROM PA01201 INNER JOIN PA01100 ON PA01201.PACONTNUMBER = PA01100.PACONTNUMBER </code></pre> <p>basically i am trying to get all the figures from PAPROJNUMBERS (C,D,F etc) to form one line of a subtotal under PACONTNUMBER</p> <p>I have tried a 'Group By' but get a Ambiguous column name 'PACONTNUMBER'???</p> <p>Any help at all much appreciated.</p> <hr> <p>Thanks for the help. Much appreciated. I will keep trying different things. </p> <p>In response to using aggregates that's not really what I was trying to do. </p> <p>Basically in my example of projects 12004C, 12004D, 12004F etc I just want them all to wrap up under 12004. so it would look something like this.............. </p> <p>Contract Figures Description:-</p> <pre><code>12004 25000 SS Bus Station 12005 xxxxx xxxxxxxx 12006 xxxxx xxxxxxxx 12007 xxxxx xxxxxxxx 12008 xxxxx xxxxxxxx </code></pre> <p>instead of how it looks at the moment:-</p> <p>Contract Figures Description</p> <pre><code>12004 6000 SS Bus Station 12004C 8000 SS Bus Station 12004D 1000 SS Bus Station 12004F 10000 SS Bus Station 12005 xxxxx xxxxxx </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload