How can i store data of database's different categories
-
I want to export data into CSV format, i have this table it has column for customer id, product category id and price of product that customer bought.

I want to export below table to CSV for all products. First row is customer id and column under every customer id is prices of products that customer bought.The question is how can i store data of prices by user and product. I tryed to use queries and arrays, but i don't know how many there will be values.

To export to CSV i store all data in QString value with ';' for next column and \n for next row and then transimt QString value.
-
Hi,
Why do you need to know the exact number of rows ?
Just loop over the result of your query and add one line for each row the query returned.
-
Hi,
Why do you need to know the exact number of rows ?
Just loop over the result of your query and add one line for each row the query returned.
@SGaist How can create query if there can be any amount of customers and products? The problem is i can't just take all prices, because they have different categories.
Looks like query should store prices by queue from 0 to last customer, and after last customer's price again 0 to last customer, but i can't figure out how to do this.
-
I want to export data into CSV format, i have this table it has column for customer id, product category id and price of product that customer bought.

I want to export below table to CSV for all products. First row is customer id and column under every customer id is prices of products that customer bought.The question is how can i store data of prices by user and product. I tryed to use queries and arrays, but i don't know how many there will be values.

To export to CSV i store all data in QString value with ';' for next column and \n for next row and then transimt QString value.
@Kuji Let me see if I have this straight. You want to take the table of data you show and produce this table with an unbounded number of columns (one per customer), a header row containing the customer number for each column, and an unbounded number of rows (as many rows as the maximum number of orders made by any customer).
0 1 2 1999 2499 1399 1349 null null -
@Kuji Let me see if I have this straight. You want to take the table of data you show and produce this table with an unbounded number of columns (one per customer), a header row containing the customer number for each column, and an unbounded number of rows (as many rows as the maximum number of orders made by any customer).
0 1 2 1999 2499 1399 1349 null null -
One issue with your CSV, you are losing the information about which product belongs to which prize unless you also state that each row corresponds to a product ID.