teradata

query to return specific date from teradata timestamp(6)

妖精的绣舞 提交于 2019-12-05 07:14:01
How can i search for a particular date for eg: '2013-10-22' from teradata timestamp(6) field? sel * from table A where date = '2013-10-22'; I tried the above query which is throwing error. Please help! You may try like this:- sel * from table A where date = date '2013-10-22'; Since in ANSI standard form (must be preceded by the keyword DATE) Check out this Something like this: where YourTimestampField >= {d '2013-10-22'} and YourTimestampField < {d '2013-10-23'} And more formally: select * from table A where cast(timestamp_column as date) = date '2013-10-22'; I'm guessing that you were just

SQL Concatenate multiple rows

北战南征 提交于 2019-12-05 06:30:27
I'm using Teradata, I have a table like this ID String 123 Jim 123 John 123 Jane 321 Jill 321 Janine 321 Johan I want to query the table so I get ID String 123 Jim, John, Jane 321 Jill, Janine, Johan I tried partition but there can be many names. How do I get this result. Even, to point me in the right direction would be great. Unfortunately there's no PIVOT in Teradata (only a TD_UNPIVOT in 14.10). If you got luck there's an aggregate UDF at your site to do a group concat (probably low possibility). Otherwise there are two options: recursion or aggregation. If the maximum number of rows per

NullPointerException after extracting a Teradata table with Scala/Spark

爱⌒轻易说出口 提交于 2019-12-05 02:45:12
I need to extract a table from Teradata (read-only access) to parquet with Scala (2.11) / Spark (2.1.0). I'm building a dataframe that I can load successfully val df = spark.read.format("jdbc").options(options).load() But df.show gives me a NullPointerException: java.lang.NullPointerException at org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowWriter.write(UnsafeRowWriter.java:210) I did a df.printSchema and I found out that the reason for this NPE is that the dataset contains null values for (nullable = false) columns (it looks like Teradata is giving me wrong information). Indeed,

Export From Teradata Table to CSV

南楼画角 提交于 2019-12-05 01:33:21
问题 Is it possible to transfer the date from the Teradata Table into .csv file directly. Problem is - my table has more that 18 million rows. If yes, please send tell me the process 回答1: For a table that size I would suggest using the FastExport utility. It does not natively support a CSV export but you can mimic the behavior. Teradata SQL Assistant will export to a CSV but it would not be appropriate to use with a table of that size. BTEQ is another alternative that may be acceptable for a one

Python PyTd teradata Query Into Pandas DataFrame

假装没事ソ 提交于 2019-12-04 21:20:03
I'm using the PyTd teradata module to query data from Teradata and want to read it into a Pandas DataFrame import teradata import pandas as pd # teradata connection udaExec = teradata.UdaExec(appName="Example", version="1.0", logConsole=False) session = udaExec.connect(method="odbc", system="", username="", password="") # Create empty dataframe with column names query = session.execute("SELECT TOP 1 * FROM table") cols = [str(d[0]) for d in query.description] df = pd.DataFrame(columns=cols) # Read data into dataframe for row in session.execute("SELECT * FROM table"): print type(row) df.append

Read Teradata query into Pandas

帅比萌擦擦* 提交于 2019-12-04 19:26:19
Has anyone found a way to read a Teradata query into a Pandas dataframe? It looks like SQLAlchemy does not have a Teradata dialect. http://docs.sqlalchemy.org/en/latest/dialects/ http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_sql.html I did it using read_sql . Below id the code snip : def dqm() : conn_rw = create_connection() dataframes = [] srcfile = open('srcqueries.sql', 'rU').read() querylist = srcfile.split(';') querylist.pop() for query in querylist : dataframes.append(pd.read_sql(query, conn_rw)) close_connection(conn_rw) return dataframes,querylist You can create

How to set up .net teradata connection in c#?

≯℡__Kan透↙ 提交于 2019-12-04 18:38:09
问题 I am trying to connect to Teradata with c#. I am using the sample code from this website using System; using System.Collections.Generic; using System.Text; using Teradata.Client.Provider; namespace Teradata.Client.Provider.HelloWorld { class HelloWorld { static void Main(string[] args) { using (TdConnection cn = new TdConnection("Data Source = x;User ID = y;Password = z;")) { cn.Open(); TdCommand cmd = cn.CreateCommand(); cmd.CommandText = "SELECT DATE"; using (TdDataReader reader = cmd

How to summarize all possible combinations of variables?

半世苍凉 提交于 2019-12-04 14:53:57
问题 I am trying to summarize the count based on the all possible combinations of variables. Here is an example data: 回答1: For this sort of query using some of the built in aggregate tools is quite straight forward. First off setup some sample data based on your sample image: declare @Table1 as table ([id] int, [a] int, [b] int, [c] int) ; INSERT INTO @Table1 ([id], [a], [b], [c]) VALUES (10001, 1, 3, 3), (10002, 0, 0, 0), (10003, 3, 6, 0), (10004, 7, 0, 0), (10005, 0, 0, 0) ; Since you want the

SQL - What is the performance impact of having multiple CASE statements in SELECT - Teradata

[亡魂溺海] 提交于 2019-12-04 09:02:58
问题 So I have a query that requires a bunch of CASE statements in the SELECT. This was not the orginal design but part of a compromise. So the query looks something like this: SELECT CONT.TABLE.FINC_ACCT_NM, CONT.TABLE.FINC_ACCT_ID, CONT.TABLE.CURR_END_OF_PERD_ACTL_VAL, CONT.TABLE.PREV_END_OF_PERD_ACTL_VAL, CONT.TABLE.VARNC_PLAN_VAL, CONT.TABLE.OUTLOOK_BDGT_PLAN_VAL, CONT.TABLE.PERD_END_RPT_DT, CONT.TABLE.PLAN_VERS_NM, CONT.TABLE.FRMT_ACTL_CD, CONT.TABLE.FRMT_PLAN_CD, CONT.TABLE.RPT_PERD_TYPE_CD,

Writing Efficient Queries in SAS Using Proc sql with Teradata

亡梦爱人 提交于 2019-12-04 08:56:25
问题 EDIT: Here is a more complete set of code that shows exactly what's going on per the answer below. libname output '/data/files/jeff' %let DateStart = '01Jan2013'd; %let DateEnd = '01Jun2013'd; proc sql; CREATE TABLE output.id AS ( SELECT DISTINCT id FROM mydb.sale_volume AS sv WHERE sv.category IN ('a', 'b', 'c') AND sv.trans_date BETWEEN &DateStart AND &DateEnd ) CREATE TABLE output.sums AS ( SELECT id, SUM(sales) FROM mydb.sale_volue AS sv INNER JOIN output.id AS ids ON ids.id = sv.id WHERE