Hidding (Blank) Data in PivotGrid - telerik

1/. My DataBase SquetchUp , and Request:
I have those 2 table :
Table_EC: Table_P:
+------+---------+------------------+ +---------+--------+--------+
| Name | IdValue | ManyOtherInfo... | | IdValue | Value1 | Value4 |
+-----------------------------------+ +---------------------------+
| STR | INT | ManyTYPE | | Int | Label | OrderBy|
+------+---------+------------------+ +---------+--------+--------+
In order to diplay in a cross table I do this request:
SELECT NAME , VALUE1
FROM Table_EC
RIGHT JOIN Table_P
ON Table_EC.VALUE1= Table_P.VALUE1
ORDER BY PAR_VALEUR4
2/. Telerik MarkUp
My RadPivotGrid declaration:
<telerik:RadPivotGrid ID="RadPivotGrid1" runat="server" OnNeedDataSource="RPG_RECAP_NeedDataSource" >
<TotalsSettings RowGrandTotalsPosition="None" RowsSubTotalsPosition="None" />
<Fields>
<telerik:PivotGridAggregateField GrandTotalAggregateFormatString="" CalculationExpression=""
UniqueName="Statut" DataField="Value1" Aggregate="Count" >
<TotalFormat Level="0" Axis="Columns" TotalFunction="NoCalculation" SortOrder="Ascending"></TotalFormat>
</telerik:PivotGridAggregateField>
<telerik:PivotGridRowField UniqueName="RowCLI" DataField="Name" />
<telerik:PivotGridColumnField UniqueName="ColumnStatut" DataField="Value1" />
</Fields>
</telerik:RadPivotGrid>
3/. Current Result:
The expected result are the same but with out the (Blank) Row
How do i achieve this ?

For now my answer is : You can't
What i have done to "fix the issue":
( By fix I mean make the information more relevant for the Customer)
Count on a null value in the AggregateField Here ValueID.
Not on Value1 will make blank row display 0 .
Dont forget to set IgnoreNullValues="true" and ShowGroupsWhenNoData="false".

Related

How to display N/A when Name column is blank for custid1 in ID column and for custid2 we have 2 entries as 1.Prem, 2. (2 is blank)

I have a table like below,I'm using vertica data base sql
| Name | Cust ID |
| | 1 |
| | 2 |
|Prem | 2 |
For cust ID 1 the name is blank, so it should display and N/A, for cust ID 2 we have 2 entries, which are 1 is blank and 2 is Prem, so blank should be ignored and should display Prem.
The final out put should be like this,
|Name | Cust ID |
|N/A |1 |
|Prem |2 |
The final output should be like this,
|Name | Cust ID |
|N/A |1 |
|Prem |2 |
This works if the non-empty name of the same cust-id is always the same in multiple rows. Note that I use the NULL value for non-existent data. An empty string and NULL are two different things, for me.
WITH
indata("name",custid) AS (
SELECT NULL , 1
UNION ALL SELECT NULL , 2
UNION ALL SELECT 'Prem', 2
)
SELECT
IFNULL(MAX("name"),'N/A') AS "name"
, custid
FROM indata
GROUP BY custid;
-- out Null display is "(null)".
-- out name | custid
-- out ------+--------
-- out N/A | 1
-- out Prem | 2

How to convert row values of a column to columns - JDBCTemplate and PostgreSQL

I currently have a table:
id | info | value | date
1 | desc | description | 19-01-1990 10:01:23
2 | lname | Doe | 19-11-1990 10:01:23
1 | fname | John | 19-08-1990 10:01:23
1 | dob | dob | 19-05-1990 10:01:23
3 | fname | Jo | 19-01-1990 10:01:23
I would like to query and grab data and do joins with multiple tables later on, so I need it to be:
id | desc | lname | fname | dob | desc | date | ... |
1 | description | Doe | John | dob | description | 19-01-1990 10:01:23 | ... |
2 | ......... | ..... | Jo | | | ... | ... |
I have tried crosstab but it does not seem to work. Any help is appreciated
Your current table is a typical denormalized key value store. You may generate the normalized output you want by aggregating by id and then using max CASE expressions:
SELECT
id,
MAX(CASE WHEN info = 'desc' THEN value END) AS desc,
MAX(CASE WHEN info = 'lname' THEN value END) AS lname,
MAX(CASE WHEN info = 'fname' THEN value END) AS fname,
MAX(CASE WHEN info = 'dob' THEN value END) AS dob
FROM yourTable
GROUP BY
id
ORDER BY
id;
Note that I don't have any column for the date, as you did not give logic for which date value should be retained for each id.
As for the Spring part of your question, you would probably have to use a native query to execute the above.

create view on Hive table: comment for each variable are lost

I created a Hive table for which we added some description in the "comment" field for each variable as shown below:
spark.sql("create table test_comment (col string comment 'col comment') comment 'hello world table comment ' ")
spark.sql("describe test_comment").show()
+--------+---------+-----------+
|col_name|data_type| comment|
+--------+---------+-----------+
| col| string|col comment|
+--------+---------+-----------+
All is good and we see the comment "col comment" in the commennt field of the variable "col".
Now when I am creating a view on this table, the "comment" field is not propagated to the view and the "comment" column is empty:
spark.sql("""create view test_comment_view as select * from test_comment""")
spark.sql("describe test_comment_view")
+--------+---------+-------+
|col_name|data_type|comment|
+--------+---------+-------+
| col| string| null|
+--------+---------+-------+
Is there a way to keep the values of the comment field when created a view ? What is the reason of this "feature" ?
I am using:
Hadoop 2.6.0-cdh5.8.0
Hive 1.1.0-cdh5.8.0
Spark 2.1.0.cloudera1
What I have observed is that, comments are not inherited even when creating a table from another table. Looks like it is the default behaviour.
create table t1 like another_table
desc t1 //includes comments
+-----------+------------+------------------+--+
| col_name | data_type | comment |
+-----------+------------+------------------+--+
| id | int | new employee id |
| name | string | employee name |
+-----------+------------+------------------+--+
create table t1 as select * from another_table
desc t1 //excludes comments
+-----------+------------+----------+--+
| col_name | data_type | comment |
+-----------+------------+----------+--+
| id | int | |
| name | string | |
+-----------+------------+----------+--+
But there is a workaround. You can specify individual columns with comment when creating a view
create view v2(id2 comment 'vemp id', name2 comment 'vemp name') as select * from another_table;
+-----------+------------+------------+--+
| col_name | data_type | comment |
+-----------+------------+------------+--+
| id2 | int | vemp id |
| name2 | string | vemp name |
+-----------+------------+------------+--+

How to use ResultSet to fetch the ID of the record

I have got a table with name table_listnames whose structure is given below
mysql> desc table_listnames;
+-------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(255) | NO | | NULL | |
+-------+--------------+------+-----+---------+----------------+
2 rows in set (0.04 sec)
It has got sample data as shown
mysql> select * from table_listnames;
+----+------------+
| id | name |
+----+------------+
| 6 | WWW |
| 7 | WWWwww |
| 8 | WWWwwws |
| 9 | WWWwwwsSSS |
| 10 | asdsda |
+----+------------+
5 rows in set (0.00 sec)
I have a requirement where if name not found under the table , i need to insert or else do nothing
I am achieving it this way
String sql = "INSERT INTO table_listnames (name) SELECT name FROM (SELECT ?) AS tmp WHERE NOT EXISTS (SELECT name FROM table_listnames WHERE name = ?) LIMIT 1";
pst = dbConnection.prepareStatement(sql);
pst.setString(1, salesName);
pst.setString(2, salesName);
pst.executeUpdate();
Is it possible to know the id of the record of the given name in this case

magento database structure?

Currently am working with magento project..
in which i have stucked on the point ..
that is when admin add any subcategory/category
by
Manage category -> custome design
here its gives two option like
Active from and Active to..
can anyone, who know about magento database, tell me where or in which table this two value store
Thanks for any suggestion or help!
I've listed the attributes for catalog categories below. Since categories are an EAV type, you'll need to look in a particular subtable to get your values. In this case, custom_design_from and custom_design_to are datetime values, and the name of your entity is catalog_category_entity, so the table you want is catalog_category_entity_datetime.
Next problem you'll find is getting the right attribute ID. Since they're liable to change, here's the SQL query to run in order to grab them:
select attribute_id, attribute_code from eav_attribute where entity_type_id = 3 and attribute_code in ('custom_design_from', 'custom_design_to');
I get 52 and 53, but YMWV. Hope that helps!
Thanks,
Joe
+----------------------+--------------+
| attribute_code | backend_type |
+----------------------+--------------+
| name | varchar |
| is_active | int |
| url_key | varchar |
| description | text |
| image | varchar |
| meta_title | varchar |
| meta_keywords | text |
| meta_description | text |
| display_mode | varchar |
| landing_page | int |
| is_anchor | int |
| path | static |
| position | static |
| all_children | text |
| path_in_store | text |
| children | text |
| url_path | varchar |
| custom_design | varchar |
| custom_design_apply | int |
| custom_design_from | datetime |
| custom_design_to | datetime |
| page_layout | varchar |
| custom_layout_update | text |
| level | static |
| children_count | static |
| available_sort_by | text |
| default_sort_by | varchar |
| include_in_menu | int |
+----------------------+--------------+
Active from is an attribute whose attribute_code is custom_design_from(attribute_id 57) and Active To is an attribute whose attribute_code(attribute_id 58) is custom_design_to.
This both attributes value are stored in database table `catalog_category_entity_datetime`.
Check above table with row like value of entity_id is your category id, attribute_id is 57 and active from value is store in value field of table same active to value is stored in value field with entity_id is your category id, attribute_id is 58.

Resources