I have a table with rows of multiple types. How do I create another table from it so that the rows in this table reflect the sum of all rows of each type from the previous table.
For e.g. I have a Table1 with 5 rows of type A, 6 rows of Type B. I want to create a table (Table2) that contains one row of type A (which is sum of all the 5 rows from Table1) and one row of type B (again this is the sum of all 6 rows from Table1).
Related
I've been trying to select multiple values from another table (i.e. texts in multiple rows) and display it on main table so that multiple values can be on one cell.
(also, I don't speak English, so some terms might sound different, sorry)
Example:
1st table:
ID
Name
Value1
1
Cell 2
A; B
2
Cell 4
B;C;D
2nd table (column Value1 is connected to the previous table's Value1 column):
ID
Value1
1
A
2
B
3
C
4
D
5
E
So in the first table I want to put both values in one cell from the 2nd table
Thank you!
At the moment, I am able to select only one value for Value1 column in the first table that is referenced to the second table.
On phpMyAdmin, I tried to add several columns on one constraint, but error occurred.
I have a requirement of making the duplicate records in a table from the number specified in a separate table. Given below the example.
Table A1 having many columns along with seg_id column. And Table B1 having many columns along with seg_id column and iteration_no column.
I have to join both the tables using seg_id column and take the value present in iteration_no column. If the value is 5 then I need to duplicate the entire seg_id row in Table A1 into 5 rows without any changes. Could you please help.
I need to alter customer_number column in organisation table so, that it would become auto-incrementable.
As in, when adding rows to the table, this certain column would get bigger number each time. It is not the id column.
Example: If there would be no rows or only rows that have no value on customer_number column, the newly added organisation row would get 1 as the value for its customer_number column. If there would be already for example two rows with values on said column - say 100 and 200 - the new row would get value 201 on that column.
Is that even possible to do by altering an existing table and column?
Can anyone explain to me what the following code does? Thanks.
1) this code joins Subscribers table records with Relatiws table records where Subscribers table phone number is equals to Relatives table column 'subscriber' value.
2)Then this code joins resulting table records from first step with Activities table records where Relatives table column 'FamilyMember' value is equal to Activities table column 'Subscriber' value.
Resulting table from step two has 10 columns
1 PhoneNumber
2 Name
3 SubscriptionDate
4 Subscriber
5 FamilyMember
6 ID
7 Subscriber
8 Date
9 Type
10 Content
3)then this code selects column 'Contents' values from resulting table from second step where name is 'Ringo Star' and type is 'Message received'.
I have a database table with 8 fields say Table(a,b,c,d,e,f,g,h).For some rows one of the field is different(say 4 different a values) while all other field values(b-h) in the schema are same.I have to make a table selecting just one rows from such rows with different a's but same b-h.That is I can select any one of the different a's and keep b-h same which they are and display it in table as 1 single row instead of 4.
SELECT MIN(a) a,b,c,d,e,f,g,h
FROM mytable
GROUP BY b,c,d,e,f,g,h