SQL Lab
clickhouse result no column header when using formatDateTime function
select BUSI_DATE AS aaa FROM DM_PORT_ASSET
SELECT formatDateTime(BUSI_DATE, '%Y-%m') as aaa FROM DM_PORT_ASSET
Related
I am trying to add a new column to a power query result that is the result of subtracting one column from another. according to the power bi documentation basic arithmetic is supported with query folding but for some reason it is showing a failure to query fold. I also tried simply adding a column populated with the number 1 and it still was not working. Is there some trick to getting query folding a new column to work on snowflake?
If the computation is made based only on data from source, then it could be computed during table import as SQL Statement:
SELECT col1, col2, col1 + col2 AS computed_total
FROM my_table_name
EDIT:
The problem with this solution is that native SQL statement for snowflake is only supported on PBI desktop and I want to have this stored in a dataflow (so pbi web client) for reusability and other reasons.
Option 1:
Create a view istead of table at source:
CREATE OR REPLACE VIEW my_view
AS
SELECT col1, col2, col1 + col2 AS computed_total
FROM my_table_name;
Option 2:
Add computed column to the table:
ALTER TABLE my_table_name
ADD COLUMN computed_total NUMBER(38,4) AS (col1 + col2);
What will be the expected result of the below.
I have table A with column1,
I'm trying to map column1 to SQ, which has 3 columns - col1, col2 and col3.
Link Column1 to col1,col2 and col3 in SQ. Now when I try to generate SQL query for SQ, what will be the result?
Since OP is waiting for answer and doesnt have informatica to test it out, let me answer to that.
if you connect one column to three columns in SQ and then connect all those three columns to next transformation, then your generated SQL will contain one column repeated thrice from source.
Here are some screenshot from a dummy map i created.
mapping screenshot -
Then here is generate SQL -
SELECT
ITEM.ITEM_NUM, ITEM.ITEM_NUM, ITEM.ITEM_NUM
FROM
ITEM
I would like to get a single value from "table2.MappedValue" for every record in table1 in Power Query Editor,
I have two tables, that have a many to one relationship, table2 is just a mapping table:
table1: ID | Values
table2: ID | MappedValue
when I try Table.Column(#"table2","MappedValue"), I get a list and not a single value.
I can do that from Table tools-> New Column, but I was wondering if that is possible in Power Query Editor.
You can do this by merging queries. In the query editor go to Home tab and select table1 click on merge and merge with table2. Next step is to expand your new column by selecting the dubble arrow in the column and select the column you want.
So far what I do is run query builder, click preview, copy content of select, paste in excel, ctrl+H replace " t1." by "" and replace "," by "".
That's not very elegant and takes a few seconds for each table, is there a better way to do that ?
My understanding is that you simply want a 'list' of the columns that are output/referenced in your query (from Query Builder).
If you are actually running the Query Builder step and a new table is created, you can query the DICTIONARY tables for information about that. For example, you could run this in a separate program:
PROC SQL;
SELECT
name AS Column_Name
FROM
DICTIONARY.COLUMNS
WHERE
libname = 'LIBRARY' AND /* Change to the name of the library the table is in. */
memname = 'TABLE'; /* Change to the name of the new table */
QUIT;
So, if you have a query like:
SELECT
Column_A,
Column_B
FROM
LIBRARY.TABLE;
The query I provided atop will give you:
Column_A
Column_B
Which you can simply copy and paste - and not need to replace any characters.
Simple question. I have a table Person. I have in it two rows:
1 Joe Doe joe.doe#ymail.com
2 Vivien Doe v.doe#gmail.com
How to write a SOCI statement, which will tell me (return) how many rows I have in my table? (Here, in my example, I have 2 rows).
To get the number of rows in an SQL table use the count(*) function like this:
select count(*) from Person
To be more specific - to get the number into C++ variable use:
int count;
sql << "select count(*) from person", into(count);