This topic is locked

Select and sum

11/20/2006 2:54:42 AM
ASPRunnerPro General questions
L
leesayer author

Sergey - you are the master! I would love help if possible on asp code that I would like to establish the following from my database. I want to have a custom query that displays results from 2 colums in a table. I have Column headings 'Model' and 'year', and want to fill a results list that shows for example that Corolla 1997 had a sum of 10, 1998 had a sum of 15, Accord 1997 had a sum of 25 etc. I also have a column called 'Quantity', which consists simply of the figure '1' for each record in the table. I have tried using a number of combinations of 'Select' and 'Sum', but I can't seem to get anything close to an acceptible syntax.

C
clig 11/20/2006

Sergey - you are the master! I would love help if possible on asp code that I would like to establish the following from my database. I want to have a custom query that displays results from 2 colums in a table. I have Column headings 'Model' and 'year', and want to fill a results list that shows for example that Corolla 1997 had a sum of 10, 1998 had a sum of 15, Accord 1997 had a sum of 25 etc. I also have a column called 'Quantity', which consists simply of the figure '1' for each record in the table. I have tried using a number of combinations of 'Select' and 'Sum', but I can't seem to get anything close to an acceptible syntax.


Something like:
Select Model, Year, COUNT(YEAR) AS No_Models FROM tblModel GROUP BY Model, Year

L
leesayer author 11/22/2006



Something like:
Select Model, Year, COUNT(YEAR) AS No_Models FROM tblModel GROUP BY Model, Year


Many thanks for the reply. I will try that, but looks like it will do the trick. Much appreciated.