I have a 4x4 table in SQL with 20 rows. I want to split this data into four pages. Page 1 has the first 10 rows of the first column, Page 2 has the first 10 rows of the second column, etc.
After every four pages, this patern repeats showing the next 10 rows from the first column, etc. How can I arrange this?
I could arrange the data of the 4x4 table into another temporary table with just one column in its schema. Then I could read a single column of this table into my report. But can I instead do this directly without an intermediary table?
The intermediary table sounds like the best solution to me. I'd just write a custom SQL command in Crystal's Database Expert to arrange the data as you see fit.
You could in theory pull this off with repeating subreports in some manner of repeating header, but it would be much less work to have SQL properly format the incoming data for you.
Related
I need some help and I know I am not the only one to deal with this issue but I am wondering if you might have some ideas on how to handle the situation of comparing two rows of data filling out start and end dates.
To give you some context, we have a huge hierarchy (approx 8,000 rows and about 12 columns wide) that is updated each year. Sometimes the values change and sometimes they don’t. When the values don’t change, then I don’t need to adjust the dates. When the values do change and a new row is added, I need to change the data.
I have attached some fake data to try and illustrate my data. I am building this in MS Access, so I think this is more of a DBA type question that is going to be manipulated via a recordset type method.
In my example I have two tables – Old Table and New Table. In each table there is a routing code field that represents my join field and primary key for this table.
The Old table represents existing data - tblMain. The New Table represents the data to be appended - tblTemp.
To append the data, I have an append query set up in Access. I perform a left join between the Old and New tables, joining on every field and append the rows that are null in the Old table. That’s fine and that is not where my issue is.
What is causing me issue is how to fill out the start and end dates.
So as you can see from my tables, we are running a zoo. Let’s just say for the sake of the argument, our zoo started off pretty simple and has become more sophisticated. We now want our hierarchy to expand out and become a bit more detailed as we are now capturing the type of animal (Level 4) and the native location (Level 5).
As you can see when comparing one table to another the routing codes are the same, so the append query has to have a join on each field. When you do this, you return the Result Table which is essentially the Old and New tables stacked on top of each other. You might think about a Union query but this is going to give me duplicates and I don’t want that.
If you notice in the Result Table there is a Start and End Date. Let’s just say I get the start and end dates via message box that pops up upon the import of the data and is held in a variable. I think there are dates in my real data but still trying to verify this.
So how do I compare (pseudo code for the logic needed)?
• For each routing code:
Compare Levels 1-5
If the routing code is the same but Levels 1 -5 are not the same
fill out the end date of the old record
fill out the start date of the new record
This idea of comparing two records and filling out a data is quite prevalent in my organization but I haven’t found a way of creating the logic that consistently works so any help or suggestions would be appreciated.
Old Table
New Table
Result Table
Explanation- In column "Raw content" i am having data like -MSH|^~\&|PYXIS|SJO|PHA|SJF1|201707171217||ACK|587044650|P|2.2|0| MSA|AA|587044650|....... Message in each row in b/w MSH data is different and i need to search for all the rows having MSH|* |* |CACPA| in place of SJO as shown in above example.. *(astric) means any value
What SQL query should be any suggestion?
Fix your data structure! You should not be storing multiple values in a single column. Instead, you should have a separate table with one row per whatever and per color. That is the right way to use a relational database.
That said, sometimes we are stuck with other people's really bad design decisions. There is a way around this:
where concat('|', colors, '|') not like '%|Red|%'
Is it possible to keep table column within the same page? It always go to the new page when table width is larger than page.
I design a report with TableA that have dynamic columns. The dynamic columns are in short format. For example: BS, BN, OT...
In order to understand column meaning, I have to create another table, TableB, below the table to explain. I want to display it horizontally. For example: BS: Basic Salary| BN: Bonus| OT: Over Time| ...
But when TableB has many columns, It go to new page and leave a lot of blank space in previous page. I want to keep columns in the same page, if possible.
I want TableB to display like this:
|X:xx| X:xx | X:xx| X:xx| (Edge of right page)
|X:xx| X:xx|
You're using a horizontal table, a great tutorial is described here
You probably have most of the horizontal table figured out, just this part is important to your issue.
Step 4
Right-click on the column header and select "Edit Group". Enter this
for the group expression: =RowNumber(Nothing). This will cause the
matrix to give you one column per row of data. Since horizontal tables
can end up rather wide, you probably want your table wrap around to
the next "line" after a specific number of columns.
Just simply count the number of rows that fit your page exactly and define this number in your column group expression as described in the tutorial.
Use Column Visibility to hide column instead of Cell Visibility. This should eliminate the blank space.
If the report is still too big, set the report interactive size to 0in,0in. This will keep everything in one page.
I have a database extract in excel and want to create a custom value in Tablue using their create calculation, which I believe is SQL based.
Basically I have a large number of feeds which all show up different amounts in a column. For example:
feed 1
feed 1
feed 2
feed 3
feed 4
feed 4
feed 4
And I want to have a sum for feed 1, feed 2, and feed 4. But in my actual DB there's about 100 feeds all with different number of appearances. I'm having troubles finding a good way to do this. If there even is one. Any help or direction would be appreciated!
I'm assuming that your list is a single column and you need a count of the number of occurrences of each feed. For the sake of example, since a column or table names were not supplied, let's call them colname and tablename.
select colname, count(*) as Ct from tablename group by colname
It would be easier to give an exact answer if you posted a small simplified subset of your spreadsheet. But assuming you have a column called "feed_name" which takes on values like "feed 1", "feed 2" etc depending on the row. Then the feed_name column should be a discrete dimension in Tableau.
Then just put the feed_name pill on a shelf, say the row shelf. And put the "Number of Records" field on another shelf, say the column shelf.
You don't need to write SQL to do this (or most tasks) in Tableau. It helps to understand SQL concepts and its very helpful to drop down to the SQL level when needed to solve tricky issues. But for most situations, you can just interactively explore the data by moving fields around and writing some simple calculations -- and let Tableau take care of generating the SQL necessary to retrieve the data needed to build the visualization you requested.
Tableau supports SQL and some NO-SQL data sources, along with some cubes too. It does that quite well and in multiple ways. You just can work more quickly and efficiently by using Tableau's visual based manipulations in most cases, and then drop to the lower level detail when needed. It just takes getting used to how Tableau operates.
I am trying to replicate a word document as a report in Reporting Services 2008r2.
I need to create a table, with some cells spanning more than 1 column. Essentially it's a 3 column table, but sometimes the 2nd column should fill the space of the 3rd.
I can't find a good way of creating this in Report Builder 3 - I have tried using a table and matrix but cannot achieve what I want.
This report is for 1 record, I want a table of data related to a record and do not want to create textboxes and rectangles and arrange them neatly to get what i want.
Each field should have its own row - but some of those rows will be split with 2 values.
Does anyone have a good method to create what I want? Please don't tell me this isn't the 'norm' and how to do the normal way - I need to replicate an existing layout.
I have solved my issue by deleting the 'Header' row from the table. Then using it like a normal table in any MS Office app, I have also ensured that my Dataset only contains 1 row which may have had some bearing on my issue...