How can I do this, and is it possible?
Please try a bit of noobish idiocy, I can't describe it better
| Monday | Tuesday | Wednesday |
+---------+---------------+-----------+
| School | Art | Verb |
| Lunch | The 3 Rows | |
| Roses | are | |
| Useless | 1 cell | |
| Dump | Number | Things |
Read about the colspan and rowspan to understand how to do this yourself, it's very simpl once you know how:
https://html.com/tables/rowspan-colspan/
Related
I'm still very new here and I have a very limited knowledge in any sql query. I am helping my company to create a database to store "Painting Reports" using LibreOffice Base. I have create a table which has more than 12 columns/fields to store the report.
My current table:
+----------+----------+------------+-----------+-----------+---------+-----------------+
| ReportID | nthCoat | DateCoat | NameCoat | Shade | BatchNo | __more_fields__ |
+----------+----------+------------+-----------+-----------+---------+-----------------+
| 1 | 1st Coat | 01/01/2020 | Luxaprime | Red Oxide | B75489 | value |
+----------+----------+------------+-----------+-----------+---------+-----------------+
| 1 | 2nd Coat | 02/01/2020 | Epilux | Grey | B98731 | value |
+----------+----------+------------+-----------+-----------+---------+-----------------+
| 1 | 3rd Coat | 03/01/2020 | Luxol | Yellow | B78937 | value |
+----------+----------+------------+-----------+-----------+---------+-----------------+
Since the table has too many columns/fields, it is not presentable in the generated report.
Hence, I would like to pivot the table to something like this:
+-----------------+------------+------------+------------+
| nthCoat | 1st Coat | 2nd Coat | 3rd Coat |
+-----------------+------------+------------+------------+
| DateCoat | 01/01/2020 | 02/01/2020 | 03/01/2020 |
+-----------------+------------+------------+------------+
| NameCoat | Luxaprime | Epilux | Luxol |
+-----------------+------------+------------+------------+
| Shade | Red Oxide | Grey | Yellow |
+-----------------+------------+------------+------------+
| BatchNo | B75489 | B98731 | B78937 |
+-----------------+------------+------------+------------+
| __more_fields__ | value | value | value |
+-----------------+------------+------------+------------+
By pivoting the table, it can accommodate the numerous columns/fields and more presentable in report. The values of "nthCoat" are fixed to 1st, 2nd and 3rd Coat.
There is no calculation of values needed. All the values are mainly varchar fields.
Can someone please help me pivot the table? Thanks in advance.
I have spent hours and tried to search the site for any existing solution but most of them involve calculations with complex query which is too much for beginner like me to understand.
SQL (HSQLDB) query to create a pivot table equivalent in LibreOffice Base
How can I return pivot table output in MySQL?
I'm not sure how to word this correctly, but I need to get the sequential number on duplicates in google sheets. For example, column Count is what I'm looking for:
+-------+-------+
| Name | Count |
+-------+-------+
| Joe | 1 |
| Lisa | 1 |
| Jenny | 1 |
| Lisa | 2 |
| Lisa | 3 |
| Joe | 2 |
| Jenny | 2 |
Sample sheet: https://docs.google.com/spreadsheets/d/1BB4bzzR3TTAfW5SwvNG_W3AsIYqlSEaSOad5wB4sdko/edit#gid=0
Any help is appreciated, thanks!
For an array-enabled solution, you could try in C1
={"Count"; ArrayFormula(iferror(SORT(ROW(A2:A),SORT(ROW(A2:A),A2:A,1),1)-MATCH(A2:A,SORT(A2:A),0)-ROW()+1))}
For more background, also see this thread.
Got it, it's: =COUNTIF($A$2:A2,A2)
I have multiple MYSQLI tables for multiple details and options about a touristic package.
I have package containing the main information, then I have package_option which contains unknown number of options added to the package, and there's package_images which contains the images.
I want to get all the information in one query, but it's prooving a difficult task. Let me explain.
I've used JOIN with but the problem was if the package_option had 3 options and the package_images had 6 images, the result was a 6*4 plus 1 (package) result table.
I would like a result containing all the fields, as many as they originaly are in the tables, not multiplied for each match in every table.
For example, the table I aim for looks like that:
-------------------------------------------------------------------------
| ID | name | description | price | option | image | size | explanation |
-------------------------------------------------------------------------
| 1 | test | some desc | 50 $ | opt. 1 | img1 | 30 | |
| | | | | opt. 2 | img2 | | |
| | | | | opt. 3 | img3 | | |
| | | | | | img4 | | |
| | | | | | img5 | | |
| | | | | | img6 | | |
Right now, the above table gets populated in every field, but it's multiplied, so I don't get only 6 rows, but 24.
I did a lot of JOINS, I'm not a beginer, which is even more frustrating, but it's the first time I try to do that, a select from multiple tables with different columns and unknown number of rows.
package_option and package_images looks like that:
-------------------------------------
| ID | package_id | option / image |
-------------------------------------
| 1 | 1 | opt. 1 / img 1 |
| 2 | 2 | opt. 2 / img 2 |
..... etc
so I don't know how many rows I'll have.
Thank you in advance for t
I have the next table setup, two tables related by an intermediate table, like this:
Client
| client_id | ...|field_X |
| 1 | ...|value1 |
| 2 | ...|value2 |
| 3 | ...|value3 |
Project
| project_id | ...|field_X |
| 1 | ...| |
| 2 | ...| |
| 3 | ...| |
| 4 | ...| |
| 5 | ...| |
| 6 | ...| |
| 7 | ...| |
client_project
| client_id | project_id|
| 1 | 2 |
| 1 | 3 |
| 2 | 4 |
| 2 | 5 |
| 3 | 6 |
| 3 | 7 |
The field_x in the table project is new and i have to fill it with the data from table client to get approximately something like this:
Project
| project_id | ...|field_X |
| 1 | ...| |
| 2 | ...|value1 |
| 3 | ...|value1 |
| 4 | ...|value2 |
| 5 | ...|value2 |
| 6 | ...|value3 |
| 7 | ...|value3 |
i dont know hot to deal with the intermediate table. i have tried this code but it doesnt work.
INSERT INTO project
(field_x)
(select field_x
from
client_project
inner join
client
where client_project.client_id = client.client_id
);
I have the idea of what i have to do but i am not able to translate it into a sql command because of the intermeditate table.Could someone explain how to deal with it?
Thanks in advance.
I assume you already have all entries in the project table but they're missing the Field_X property? So what you need is an update, not an insert
UPDATE project p, client c, project_client pc SET p.Field_X=c.Field_X WHERE p.ID=pc.ProjectID AND c.ID=pc.ClientID
However, be advised that having the same data in two places is not a good practise; if possible always put one fact in only one place.
I have a data source which is pulling in event attendance information which looks like the following table.
Note that one booking can contain multiple attendees, causing duplication in the Amount column.
+------------+-----------+---------------+----------+
| Date | Booking | Booking Price | Attendee |
+------------+-----------+---------------+----------+
| 01/01/2011 | Booking 1 | £300.00 | Alice |
| 01/01/2011 | Booking 1 | £300.00 | Bob |
| 01/01/2011 | Booking 1 | £300.00 | Dave |
| 01/01/2011 | Booking 2 | £200.00 | Frank |
| 01/01/2011 | Booking 2 | £200.00 | Julie |
| 02/01/2011 | Booking 3 | £100.00 | Anne |
+------------+-----------+---------------+----------+
The Report should end up a bit like this:
+------------+-----------+---------+
| Date | Booking | Amount |
+------------+-----------+---------+
| 01/01/2011 | Booking 1 | £300 |
| | Alice | |
| | Bob | |
| | Dave | |
+------------+-----------+---------+
| | Booking 2 | £200 |
| | Frank | |
| | Julie | |
+============+===========+=========+
| TOTAL FOR 01/01/2011 | £500 |
| |
| |
+============+===========+=========+
| 02/01/2011 | Booking 3 | £100 |
| | Anne | |
+============+===========+=========+
| TOTAL FOR 02/01/2011 | £100 |
| |
| |
+============+===========+=========+
(That pretty much exhausts my ascii-art table skills!)
The problem I have is that because the amount is showing for each delegate, the aggregate functions count them all, so date for 01/01/2011 shows as £1300, instead of £500
I don't need any values next to the attendees, so I could pull it in a separate data set, but I can't seem to add a table into a tablix cell, so don't know how that would work.
The version of SSRS is key here. In SSRS 2008R2, you can now nest aggregate functions:
So this would now be a valid expression:
=SUM(FIRST(Fields!BookingPrice.Value , "BookingGroupName") , "DateGroupName")
If you aren't yet on 2008R2 then you can do some tricks with embedded code to keep a running total: http://beyondrelational.com/blogs/jason/archive/2010/07/03/aggregate-of-an-aggregate-function-in-ssrs.aspx
The key here is that you add to the total in the embedded code once per group. Then retrieve the total and clear it out at the end of the group.