Answer the question
In order to leave comments, you need to log in
How to select'om get the sum of all columns starting with X? (mssql)
I have a table:
id, name, a1,a2,a3,..., an
where a1-an is in decimal format, null is possible.
n - arbitrary number (the number of columns may change over time)
I would like to get the sum of all columns starting with 'a' in one query, for example:
table:
2 milk 1 3 5
3 meat 5 6 2
Select id, sum
2 9
3 13
Thank you.
Answer the question
In order to leave comments, you need to log in
Normalize the base and get rid of the crooked storage method. Move the quantity of goods in stores to a separate table (`product id`, `shop id`, `quantity`).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question