General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Summing the Sum of variants in Select Statement
Here's my current sql statement:
SELECT ID, desc, SUM(QUANT) as xQuant FROM TEST GROUP BY ID
The ID has variants, AB001HB, AB001SB, etc. Right now the statement shows the sum of the quant for each variant. I want to show the sum of the quantity (quant) of the substring(ID,1,5), thus combining the sums for the variants.
SELECT substring(ID,1,5), desc, SUM(QUANT) as xQuant FROM TEST GROUP BY substring(ID,1,5) gives an error message stating that this is an illegal group by clause.
What changes should I make to the sql statement to make this work?
Thanks in advance.
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only