集計関数
COUNT
クエリ条件に一致する行の数を返します。
SELECT COUNT(*) FROM INVOICES WHERE CustomerName = 'NewTech Industries'
COUNT
クエリ条件に一致する行の数を返します。
SELECT COUNT(AnnualRevenue) FROM INVOICES WHERE CustomerName = 'NewTech Industries'
COUNT(DISTINCT)
クエリ条件に一致する、null 以外の個別のフィールド値の数を返します。
SELECT COUNT(DISTINCT InvoiceId) AS DistinctValues FROM INVOICES WHERE CustomerName = 'NewTech Industries'
AVG
カラムの値の平均を返します。
SELECT InvoiceNumber, AVG(AnnualRevenue) FROM INVOICES WHERE CustomerName = 'NewTech Industries' GROUP BY InvoiceNumber
MIN
カラムの値の最小値を返します。
SELECT MIN(AnnualRevenue), InvoiceNumber FROM INVOICES WHERE CustomerName = 'NewTech Industries' GROUP BY InvoiceNumber
MAX
カラムの値の最大値を返します。
SELECT InvoiceNumber, MAX(AnnualRevenue) FROM INVOICES WHERE CustomerName = 'NewTech Industries' GROUP BY InvoiceNumber
SUM
カラムの値の合計を返します。
SELECT SUM(AnnualRevenue) FROM INVOICES WHERE CustomerName = 'NewTech Industries'