crystal reports, populating a column - crystal-reports

I have a crystal report which fetches data from a table. It is then displayed in a tablular format. Now I want to add a new column in the report. The values for the new column will be based on the values of an already existing column which is getting populated from the table. The relation is based between the tables.
For eg:
Currently crystal report fetches data from XYZ table. The values of columns column1 and column2 are displayed in the report. Now I am adding a new field in crystal report to be displayed. The values for this field is obtained from a column of another table, say column3 of table ABC. Table ABC has column3 and column4. The relation will be like, i have to select ABC.column3 where XYZ.column2=ABC.column4.
How to achieve this in crystal report.
Thanks in advance

In the report creation wizard, select both your XYZ and ABC tables, similar to this
Then in the next step, setup the relation [XYZ.column2=ABC.column4], similar to this
Now in the next step, select all the columns you want to display from both tables, similar to this
That should take care of your requirement.

Related

Do I need to match the column order of my CREATE TABLE statement to that of my import data sheet?

I have an Excel CSV data sheet and I would like it to be imported into a new PostgreSQL table.
The Excel CSV data sheet has the columns in this order:
OrderDate, Region, Rep, Item, Units, Unit Price
This is my CREATE TABLE statement:
CREATE TABLE officesupplies (
region varchar(20)
order_date,
rep_first_name varchar(30),
unit_price float
units float
)
Notice how the order of my columns in my Create Table statement do not match the Excel. I've tested this and it does not work but I'm wondering the 'why' behind it not being able to import. Just wondering, thanks in advance!
You can specify the columns in COPY. That way you can load data where the column order is different from your table.
In your case, you should use
COPY officesupplies
(order_date, region, rep_first_name, ...)
FROM 'filenaame';
I see that you have a column Item in your file that does not seem to match any table colum. That won't work — in that case you will have to load the data into a –staging table” first or use third party software like pgLoader.

SQL Server DB Design - Single table with 150 Columns in one table or dynamic Pivot

I'm recreating a DB and I have a table with 150 columns and it has 700 rows currently (small dataset) - It will likely take 10 more years to get to 1000 rows.
My question:
Most of my data is normalized. About 125 fields contain a single numeric value (hours, currency, decimals, and integers). There are 10 or so columns that can have multiple values.
Do I continue to use the single table with 150 Rows?
Or
Do I create cross-reference tables and use a pivot query to turn my rows into columns? Something like this:
**c_FieldNames** **cx_FieldValues** **Project**
id int identity (PK) id int identity(1,1) ProjID int (PK)
fkProjectID int ProjectName
FieldName nvarchar FieldNameID int (FK to id from c_fieldNames)
Decimals nvarchar(2) FieldValue numeric(16,2)
The decimals would tell me how many decimal places a given field would need - I'd like to incorporate that into my query... Not sure if that's possible.
For each of my 125 fields with numbers, I would create a row in the cx_FieldNames table which would get an ID. That ID would be used in the FieldNameID as a foreign key.
I would then create a view a pivot table that would create a table of the 125 rows dynamically in addition to my standard table or so rows to look like the table with 150 columns.
I'm pretty sure I will be able to use a pivot table to turn my rows into columns. (Dynamically display rows as columns)
Benefits:
I could create a table for reports that would have all the "columns" I need for that report and then filter to them and just pull those fields dynamically.
Reports
ReportID int
FieldID int
The fieldID's would be based on the c_FieldName id's and I could turn all required field names (that are in the rows) into headers and run a vast majority of reports based on dynamic sql generated based on the field names. Same applies to all data structured... [Edit from Author] The more I think about this, I could do this with either table structure, which negates the benefits I saw here, as I am adding complexity for no good reason, as pointed out in the comments.
My thought is that it will same me much development time as I can use a pivot table to generate reports and pull data on the fly without much trouble. Updating data will be a bit of a chore, but not that much more than normal. I am creating a C#.NET Website with Visual Studio (hosted on Azure) to allow users to view, update, run reports on the data. Any major drawbacks in this structure? Is this a good idea? Are 125 columns in a Pivot too many? Thanks in Advance!

Update of SSRS DataSets Data

I generated a report using a table 't' which has two columns ID,Name I generated a Report which displays the Table t Using SSRS My problem is After generation of report i have inserted one more record into table t but the new record which i have inserted is not viewed in the report , how to update the datasets data so that it reflects new changes in table t

Table alias and datatables

I am triying to fill a report with datatables. The report has two tables which are
he same but with diferent alias. In c# I create a datatable for one of them with the records that must be shown and another datatable with the other table info. Crystal only gets info from the first datatable to fill the two tables so the shown data is wrong. Can I fill the two tables that are the same but diferent alias with two diferent datatables?
This is the same problem that I wrote yesterday but simplier.
Thanks for all,
Crystal Reports does support duplicate tables with aliases.
The problem may be the link. If your trying to display the two tables on the report both there's no JOIN or WHERE statement.
The table would need a link with itself. Here's a link to a tutorial on join a table to itself
select * from tbl1 as child join tbl1 as parent on parent.primarykey = child.foreignkey;

Is it possible to make a TABLE PARAMETER in CR?

I would like to ask , is that got possible to change the table name just by using the TABLE PARAMETER setting? but the column name consists in the both table are the same.
eg:
table 1(dailyregistration)
table 2(dayreg)
P.S: both table got same column name, just the table name had change to (dayreg)
select * from ????????
I'm not too sure what you mean by TABLE PARAMETER, but it is not possible to use a Crystal parameter as one of the tables in the report's source. You can only achieve this effect by either writing your own application to set the data location to the one you want, or by using a stored procedure containing dynamic SQL and the table name as a parameter.