How do I clear the following Syntax Error in Amazon Redshift - amazon-web-services
I receive the following error message when attempting to run the following:
The database reported a syntax error:
Amazon Invalid operation: syntax error at or near "." Position: 3952;
select a.*,
b.*,
c.*,
a1."lte_tbl_employee_first_name" as "lte_idb_relocation.sent_by_first_name",
a1."lte_tbl_employee_last_name" as "lte_idb_relocation.sent_by_last_name",
a2."lte_tbl_employee_first_name" as "lte_idb_return.received_by_first_name",
a2."lte_tbl_employee_last_name" as "lte_idb_return.received_by_last_name",
a3."lte_tbl_employee_first_name" as "lte_idb_shipment.order_filler_first_name",
a3."lte_tbl_employee_last_name" as "lte_idb_shipment.order_filler_last_name",
a4."lte_tbl_employee_first_name" as "lte_idb_shipment.order_taker_first_name",
a4."lte_tbl_employee_last_name" as "lte_idb_shipment.order_taker_last_name",
a5."lte_tbl_employee_first_name" as "lte_idb_shipment.shipped_by_first_name",
a5."lte_tbl_employee_last_name" as "lte_idb_shipment.shipped_by_last_name",
a6."lte_tbl_employee_first_name" as "lte_idb_shipment.requestor_first_name",
a6."lte_tbl_employee_last_name" as "lte_idb_shipment.requestor_last_name",
a7."lte_tbl_employee_first_name" as "lte_idb_shipment.shipped_by_first_name",
a7."lte_tbl_employee_last_name" as "lte_idb_shipment.shipped_by_last_name",
a8."lte_tbl_employee_first_name" as "lte_idb_transaction.entered_by_first_name",
a8."lte_tbl_employee_last_name" as "lte_idb_transaction.entered_by_last_name",
b1."lte_tbl_hospital.name" as "lte_idb_invoice.customer_name",
b2."lte_tbl_hospital.name" as "lte_idb_return.returned_by_customer_name",
b3."lte_tbl_hospital.name" as "lte_idb_relocation.relocate_from_customer_name",
b4."lte_tbl_hospital.name" as "lte_idb_transaction.invoiced_customer_name",
b5."lte_tbl_hospital.name" as "lte_idb_shipment.shipped_to_customer_name",
c1."lte_tbl_return_code.description" as "lte_tbl_return_code.return_reason_description",
c2."lte_tbl_return_code.hold_code",
c3."lte_tbl_return_code.destroyed_at_hospital",
c4."lte_tbl_inventory_type.inventory_type",
c5."lte_tbl_inventory_type.description",
c6."tbl_transaction_status.status_description",
c7."lte_idb_transaction.transaction_id",
c8.CONCAT("lte_idb_transaction.transaction_number_prefix", "lte_idb_transaction.transaction_number_sequence") as "lte_idb_transaction.transaction",
c9."lte_idb_transaction.transaction_datetime",
c10."lte_idb_transaction.invoice_number",
c11."lte_idb_transaction.entered_by",
c12."lte_idb_transaction.transaction_status",
c13."lte_idb_transaction.invoiced_customer",
c14."lte_idb_invoice.total_amount",
c15."lte_idb_invoice.invoice_status",
c16."lte_idb_invoice.date_generated",
c17."lte_idb_invoice.customer_code",
c18."lte_idb_line_item.line_item_id",
c19."lte_idb_line_item.product_id",
c20."lte_idb_line_item.price",
c21."lte_idb_line_item.product_code",
c22."lte_idb_line_item.quantity",
c23."lte_idb_line_item.comments",
c24."lte_idb_line_item.expires",
c25."lte_idb_line_item.blood_type",
c26."lte_idb_line_item.biohazard",
c27."lte_idb_line_item.licensed",
c28."lte_idb_service.po_number",
c29."lte_idb_service.auto_price",
c30."lte_idb_service.debit",
c31."lte_idb_relocation.sent_by",
c32."lte_idb_relocation.auto_price",
c33."lte_idb_relocation.po_number",
c34."lte_idb_relocation.relocate_from",
c35."lte_idb_return.returned_by",
c36."lte_idb_return.received_by",
c37."lte_idb_return.return_code" as "lte_idb_return.return_reason",
c38."lte_idb_return.ra_number" as "lte_idb_return.r/a_number",
c39."lte_idb_return.auto_price",
c40."lte_idb_shipment.shipped_to",
c41."lte_idb_shipment.shipped_by",
c42."lte_idb_shipment.order_date",
c43."lte_idb_shipment.order_filler",
c44."lte_idb_shipment.order_taker",
c45."lte_idb_shipment.requestor",
c46."lte_idb_shipment.transportation_code",
c47."lte_idb_shipment.po_number",
c48."lte_idb_shipment.autologous",
c49."lte_idb_shipment.auto_price",
c50."lte_idb_shipment.emergency_shipment",
c51."lte_idb_shipment.order_number_external"
from "lte_idb_transaction_joined" c., "raw_lte_tbl_employee" a.,
"raw_lte_tbl_hospital" b.,
left JOIN "raw_lte_tbl_employee" a1
on c."lte_idb_relocation.sent_by" = a1."lte_tbl_employee_code"
left join "raw_lte_tbl_employee" a2
on c. "lte_idb_return.received_by" = a2."lte_tbl_employee_code"
left join "raw_lte_tbl_employee" a3
on c."lte_idb_shipment.order_filler" = a3."lte_tbl_employee_code"
left join "raw_lte_tbl_employee" a4
on c."lte_idb_shipment.order_taker" = a4."lte_tbl_employee_code"
left join "raw_lte_tbl_employee" a5
on c."lte_idb_shipment.shipped_by" = a5."lte_tbl_employee_code"
left join "raw_lte_tbl_employee" a6
on c."lte_idb_shipment.requestor" = a6."lte_tbl_employee_code"
left join "raw_lte_tbl_employee" a7
on c."lte_idb_shipment.shipped_by"= a7."lte_tbl_employee_code"
left join "raw_lte_tbl_employee" a8
on c."lte_idb_transaction.entered_by" = a8."lte_tbl_employee_code"
left join "raw_lte_tbl_hospital" b1
on c."lte_idb_invoice.customer_code" = b1."lte_tbl_hospital.code"
left join "raw_lte_tbl_hospital" b2
on c."lte_idb_return.returned_by" = b2."lte_tbl_hospital.code"
left join "raw_lte_tbl_hospital" b3
on c."lte_idb_relocation.relocate_from" = b3."lte_tbl_hospital.code"
left join "raw_lte_tbl_hospital" b4
on c."lte_idb_transaction.invoiced_customer" = b4."lte_tbl_hospital.code"
left join "raw_lte_tbl_hospital" b5
on c."lte_idb_shipment.shipped_to" = b5."lte_tbl_hospital.code"
This is likely to cause that type of problem:
from "lte_idb_transaction_joined" c.,
"raw_lte_tbl_employee" a.,
"raw_lte_tbl_hospital" b.,
There should not be a period after the alias name.
Related
Wrong field names on Postgresql with ADO
I'm trying to get data from a PostgreSQL database using ADO and official PostgreSQL ODBC driver. In some cases I get wrong field names when using NextRecordset(). It looks like a bug in a driver. Is there any workaround for this? Here is a small example. It prints 'g1' for the last field of the second recordset, but it must be 'g2'. SQL Create Table Test ("Field" int); C++ _bstr_t strCnn("Provider='MSDASQL';Driver=PostgreSQL Unicode;uid=postgres;Server=127.0.0.1;port=5432;database=MyDB;pwd=password;"); _RecordsetPtr pRstCompound = NULL; TESTHR(pRstCompound.CreateInstance(__uuidof(Recordset))); auto Statement = "Select '1' a1, '2' b1, '3' c1, '4' d1, '5' e1, '6' f1, \"Field\" g1 From Test;\n" "Select '1' a2, '2' b2, '3' c2, '4' d2, '5' e2, \"Field\" f2, '7' g2 From Test;\n"; pRstCompound->Open(Statement, strCnn, adOpenForwardOnly, adLockReadOnly, adCmdText); int intCount = 1; while (!(pRstCompound == NULL)) { printf("\n\nContents of recordset #%d\n", intCount++); auto Fields = pRstCompound->Fields; long const nFields = Fields->Count; for (long nField = 0; nField < nFields; ++nField) printf("%s%s", (LPCSTR)(_bstr_t)Fields->GetItem(nField)->Name, nField + 1 == nFields ? "\n" : "\t"); pRstCompound = pRstCompound->NextRecordset(nullptr); } Output: Contents of recordset #1 a1 b1 c1 d1 e1 f1 g1 Contents of recordset #2 a2 b2 c2 d2 e2 f2 g1 Expected output: Contents of recordset #1 a1 b1 c1 d1 e1 f1 g1 Contents of recordset #2 a2 b2 c2 d2 e2 f2 g2
Is it possible to use arrayformula to copy the values above if the cell on its left is empty?
I'm trying to populate a column (Cell C2) with the value of the cell in the column to its left (Cell B2) if B2 is not empty; if B2 is empty, then C2 equals to C1. If B3 is not empty, then C3 equals to B3; if B3 is empty, C3 equals C2. I try using an array formula, but it returns circular reference error. And I certainly can't use INDEX and INDIRECT either. Please help. The sample file: https://docs.google.com/spreadsheets/d/1TXz5m5LtTF632bMrwIIDlO-4NMavgs6HA4FE8_BFhRs/edit?usp=sharing
paste in C3 cell: =ARRAYFORMULA(IF(D3:D<>"", IF(ROW(B3:B) <= MAX(IF(D3:D<>"", ROW(B3:B))), TEXT(VLOOKUP(ROW(B3:B), FILTER({ROW(B3:B), B3:B}, LEN(B3:B)), 2), "dd mmm yyyy"), ), ))
You can use vlookup on the row number: =ArrayFormula(to_date(if(D3:D="","",vlookup(row(A3:A),if(B3:B<>"",{row(A3:A),B3:B}),2,true))))
Nested IF AND OR in Excel
How do I write the formula for the following: if B2 = "SF" and D2 = "1" then H2 = E2 + .75 else if B2 = "SF" and D2 = ".25" then H2 = E2 + .625 else if B2 = "CW" and D2 = "1" then H2 = E2 + 1 I want my answers to be in H2, with data being entered into B2, D2 and E2.
=if(AND(B2="SF",D2=1)=TRUE,E2+0.75,if(AND(B2="SF",D2=0.25)=TRUE,E2+0.625,if(AND(B2="CW",D2=1)=TRUE,E2+1,0))) Regards
Hive left semi join with where clause
I'm running this query in Hive 13, but it won't compile. (It's continuing to throw ClassCastExceptions saying it can't be converted to a query.) The query is set hive.auto.convert.join=false; create table J as select c1, c2, c3, c4 from A left semi join B on (A.c1 = B.c1) where ((c2 not in ('string_literal_1', 'string_literal_2', 'string_literal_3')) and (c3 >= (cast('${hiveconf:start_time}' as bigint)-24*60*60)*1000)); Why won't this run?
Splunk query to compare two fields and select value from 3rd field if the comparison match
I am very new to splunk and need your help in resolving below issue. I have two CSV files uploaded in splunk instance. Below mentioned is each file and its fileds. Apple.csv a. A1 b. A2 c. A3 Orange.csv a. O1 (may have values matching with values of A3) b. O2 My requirement is as below: Select set of values of A1,A2,A3 and O2 from Apple.csv and Orange.csv where A1=”X” and A2=”Y” and A3 = O1 and display the values in a table: A1 A2 A3 X Y 123 LP HJK 222 X Y 999 O1 O2 999 open 123 closed 65432 open Output A1 A2 A3 O2 X Y 123 Open X Y 999 closed Very much appreciate your help.
You could do this source="apple.csv" OR source="orange.csv" | eval grouping=coalesce(A3,O1) | stats first(A1) as A1 first(A2) as A2 first(A3) as A3 first(O2) as O2 by grouping | fields - grouping Although I would think that considering the timestamp of the events might also be important...