Я не знаю, как Ваше Изображение объявляется, но предположите, что у нас есть это объявление XAML:
<Image x:Name="img">
<Image.Source>
<BitmapImage UriSource="test.png" />
</Image.Source>
</Image>
Затем можно преобразовать содержание test.png к массиву байтов как это:
var bmp = img.Source as BitmapImage;
int height = bmp.PixelHeight;
int width = bmp.PixelWidth;
int stride = width * ((bmp.Format.BitsPerPixel + 7) / 8);
byte[] bits = new byte[height * stride];
bmp.CopyPixels(bits, stride, 0);
Не забывайте, что если вы смешиваете сгруппированные (например, SUM) поля и негруппированные поля, вам нужно ГРУППИРОВАТЬ по одному из несгруппированных полей.
Попробуйте это :
SELECT SUM(something) AS fieldname
FROM tablename
ORDER BY fieldname
ИЛИ это:
SELECT Field1, SUM(something) AS Field2
FROM tablename
GROUP BY Field1
ORDER BY Field2
И вы всегда можете выполнить производный запрос следующим образом:
SELECT
f1, f2
FROM
(
SELECT SUM(x+y) as f1, foo as F2
FROM tablename
GROUP BY f2
) as table1
ORDER BY
f1
Много возможностей!
Without a GROUP BY clause, any summation will roll all rows up into a single row, so your query will indeed not work. If you grouped by, say, name, and ordered by sum(c_counts+f_counts), then you might get some useful results. But you would have to group by something.
Вот как вы это делаете
SELECT ID,NAME, (C_COUNTS+F_COUNTS) AS SUM_COUNTS
FROM TABLE
ORDER BY SUM_COUNTS LIMIT 20
Функция СУММ суммирует все строки, поэтому порядок по предложению
бесполезен, вместо этого вам придется использовать сгруппировать по пункту
.
The problem I see here is that "sum" is an aggregate function.
first, you need to fix the query itself.
Select sum(c_counts + f_counts) total, [column to group sums by]
from table
group by [column to group sums by]
then, you can sort it:
Select *
from (query above) a
order by total
EDIT: But see post by Virat. Perhaps what you want is not the sum of your total fields over a group, but just the sum of those fields for each record. In that case, Virat has the right solution.