Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8451

Re: Creating a query with unrelated tables

$
0
0

Hi Joseph,

 

When you use so-called aggregate functions, like SUM, you need to group all fields that are not in such a function.

 

So please add the GROUP BY statement at the end of your query like this:

GROUP BYT2.callID, T2.manufSN, T2.internalSN, T2.itemName, T1.DocPstDate

 

As you can see, we group all fields except for T0.DocTotal, because it is in the SUM function


Also, you cannot have the T0.DocNum field in the result set, so please remove that from the SELECT statement

 

When you want to add a totals row using the UNION statement, you need to put the same number of "fields" into the SELECT statement. My previous example would work because there were 2 fields in the top query, and 2 fields in the bottom (totals) query.

 

Regards,

Johan


Viewing all articles
Browse latest Browse all 8451

Trending Articles