we are struggling upon make imported orders unique, through a transactionID Data Source template.
In fact, this template does not consider a "purchaseID" column, and it does not parse this variable if we force it into the template.
At the moment, we set one row for every product purchased by the same "transactionID customer", with the addictional fields below:
Date Evar 22 Category Product Orders Quantity transactionID
06/06/2015 evar_value category product_name 1 1 123456
06/06/2015 evar_value category2 product_name2 1 2 123456
... ... ... ... .. .. ... ... ... ... ... ... ... ... ... ...
This example will produce 2 Orders for the "123456" customer, even if it's the same one including 3 Units (Quantity) of 2 products.
So we expected just 1 Order for this customer.
We supposed the transactionID could be a unique key, working as the purchaseID, but it does not.
Then we tried to put all the products in the same row, removing the Category column and exploiting the "s.products" format, as below:
06/06/2015 evar_value category;product_name,category2;product_name2 1 2 123456
Now the Quantity field gets 2 units.
With this template we were closer to the goal, because the Order was correctly recognized as unique.
The issue here concerns the Products, because Data Source always seems to expect an addictional one as the first.
In this example, beside "product_name" and "product_name2" an "Unspecified" product will be reported.
To sum up: how Orders could be recognized as unique when imported through transactionID, but irrespective of template (default or custom)?
You have to use full processing data sources in this case as it will bind order to visitor.
Workaround
If you want to use this template then in first column pass 1 against order and against other pass 0 each.
Hope this helps!
Related
I'm trying to develop a new products database for a client and I am having a hard time finding a solution to handle the many different prices a product can have.
Variables that can affect the price of a product:
region (where the customer lives).
customer type (whether they're a new customer or a registered customer).
order type (whether you want to purchase the item once or subscribe monthly).
store type (there were many store types, but now they're transitioning to one, but I don't know if they will add more in the future again so I want this to be flexible
Product Table
id
product_name
sku
description
1
Vanilla Protein Powder
1111
This is a description...
Attributes Table
id
associate_type
region
store
currency_code
order_type
1
2
1
11
usd
1
2
2
1
11
usd
2
Product Attributes Table
id
price
product_id
attribute_id
1
49.95
1
1
2
29.95
1
2
I was initially thinking this would be a good route to go, but the issue that arises is on the product page I want to display the price of the product if you want to purchase it once and the price if you wanted to subscribe. The same issue would happen if I also wanted to show a list of product cards on a product category page displaying both prices.
The issue I run into
When I write a query to get the correct products with the correct price lines, I would filter all the products by the variables mentioned above, but I will always want the subscription price and the one-time price, so in the query, I would have to include WHERE order_type = 1 AND order_type = 2 but doing this would return duplicate records of the product/ products because of the different prices for a one-time purchase and a subscription purchase.
Is there a better way to set up the tables I have so that the query would not return duplicate records of the product/ products? Or is there a way to write the query to handle this for me? Or do I even need to switch up my database design altogether?
I have a movie database in DB2.It has one field as class with around 15-16 distinct element in class field and another field is Day_of_year. Each day_of_year has ticket sales for almost all the classes & in database the order of appearance of class elements varies in some random order, not based on ticket sales. I want to find day_of_year where gold_class (an element in class field)
appears as first record
Can you please suggest me the query to do that?
So data type for day_of_year is INTEGER & class is VARCHAR(40)
Here is my sample data
Day_of_year Class
1 Gold_Class
1 Class_A
1 Class_B
1 Class_C
1 Class_D
1 Class_E
1 Class_F
2 Class-G
2 Class-GB
2 Class-H
2 Gold_Class
2 Class-P
2 Class-K
I want to run a query to get the day of year having Gold_Class
in first row. For example here it's day-1
How can I want print the same field twice with different value for each?
My Product and Shop tables are linked with product_id as the primary/foreign key.
Product
product_id
product_name
Shop
shop_id
product_id
quantity_product
When I use Expert Selection, I take all products on Shop_id 1 and Shop_id 2 (if Shop_id is in {1,2}...). Now I want to print 2 different quantity_product fields from Shop 1 and Shop 2 in the same line as my product_id. Something like:
product_name quantity_product(shop_id: 1) quantity_product(shop_id: 2)
1 10 20
I tried adding a new link in my database scheme with another Shop table, but it didn't work out.
You can set up a CrossTab in the summary section to handle any number of Shops. (So long as there's room on the report for all the shop columns)
If that doesn't work you can manually set up a summary for each Shop:
Keep in mind both of these solutions will need to be placed in a Footer section instead of the Details.
Wondering the best SQL to handle below situation: Client only wants to see invoices that have been declined. I started with only show me when STATUS_ID = 2, but then realized that it was paid as it was resubmitted and accepted so that didn't work. What is the best way to handle 2 records like below where I don't want the SQL to return any records if manifest + order code have a 1. Would you do a Min on Status ID or something of that nature?
VENDOR NAME manifest ORDER_CODE STATUS_ID
VENDOR 12345 BHGSDKJF1234 RU07 2 (invoice decline)
VENDOR 12345 BHGSDKJF1234 RU07 1 (paid)
This trick can be work for you in this case, but it's not solve the general case (what happens if the STATUS_ID for paid is 3, and all possible values are 0-5?)
you can use in general SWICH-CASE clause, that gives you some 1 (true) if the client has STATUS_ID = 1, and 0 otherwise. Then, pick the MAX() for each invoice.
You can also consider another design that might work for you:
Add time\time-stamp column (Maybe, for your purpose, you can use SYSDATE time for insertion time of the record to db).
After you have a time column, you probably can choose the columns with the last time STATUS_ID for each invoice (get the STATUS_ID in the row with the max time).
I'm working in Pentaho 4.4.1-GA (Kettle / PDI). The database is Postgres.
I need to be able to insert multiple records into a fact table based on the fields that come from a single record. The single record contains fields:
productcode1, price1
productcode2, price2
productcode3, price3
...
productcode10,price10
So if there was a value for each of the 10 productcode / prices then I'd need to insert a total of 10 records into the fact table. If there were values for 4 of the combinations, then I'd need to insert 4 records into the fact table, etcetera. All field values for the fact records would be identical except for the PK (generated by sequence), product codes, and prices.
I figure that I need some type of looping construct which would let me check whether or not a value was present for each productx field, and if so, do an insert/update step on the fact table with the desired field values. I'm just not sure how to do this in Pentaho.
Any ideas? All suggestions are welcome :)
Thank You,
Rakesh
Could you give a sample input and output for your scenario??
From your example data I can infer that if there are 10 different product codes and only 4 product prices you want to have 4 records inserted into your table. Is that so?
Well for a start you can add a constant value of 1 to those records by filtering for NOT NULL and then use an Group BY Step to count the number of 1's. This would give you the count. BTW it would be helpful if you could provide more details on what columns you would be loading as there are ways to make a PDI transformation execute multiple times