I am trying to combine and count with a database.
I have this data: I want to create a column to calculate the number of rows that match the value of the I want this output: What have I got so far ... So far I have Any help would be great! / * query * /
column_a | Column_b ------------------- A | 1a. 2a. 2b | 3b 3a. 3b 3
column_a to
a_total I am Then I want to put together the group
column_b values for the type of AD. The data will then output by descending
a_total , then descending column_by.
column_a | Column_b | A_total | BTatal --------------------------------------- A | 3 | 4 | 1a. 2 | 4 | 2a. 1 | 4 | 1b 3 | 3 | 3
SELECT column_a, column_b, COUNT (* ) This group from AS b_total by column_a, column_b, ORDER BY column_b, DESC, b_total DESC which puts
column_b in the order with the correct
b_total , but how uncertain I am Get the sum of
a_total in
column_a within the same question.
test the database; Use examination; Create table T (A VARCHAR (5), BIT); INSERT T VALUE ('A', 1), ('A', 2), ('A', 2), ('B', 3), ('B', 3), ('A', 3) , ('B', 3);
SELECT xx.a, xx.b, yy.a_total, zz.b_total (select a, bt Xx Inner Join (SELECT COUNT (a) as a_total, a FROM T group a) yy ON xx.a = yy.a INNER JOIN (SELECT COUNT (a) AS b_total, a, bf to t by group a, B) Juz on (zz.a = xx.a and zz.b = xx.b)
Comments
Post a Comment