jen
07/16/2020, 6:34 PMSELECT column_a, (SELECT column_b FROM table_b ORDER BY column_c LIMIT 1) AS referenced_column FROM table_a
stalbert
07/16/2020, 6:46 PMjen
07/16/2020, 6:46 PMstalbert
07/16/2020, 6:47 PMjen
07/16/2020, 6:48 PMjen
07/16/2020, 6:50 PMjen
07/16/2020, 6:50 PMSELECT column_a, (
SELECT column_b
FROM table_b
WHERE table_b.column_c = (
SELECT MAX(column_c)
FROM table_b
)
) AS referenced_column
FROM table_a
stalbert
07/16/2020, 7:05 PMjen
07/16/2020, 7:11 PMjen
07/16/2020, 7:11 PMstalbert
07/16/2020, 7:12 PMstalbert
07/16/2020, 7:13 PMjen
07/16/2020, 7:17 PMjen
07/16/2020, 7:19 PMjen
07/16/2020, 7:19 PMtdietrich
07/16/2020, 7:28 PMstalbert
07/16/2020, 10:46 PMClay Roper
07/17/2020, 2:10 AMClay Roper
07/17/2020, 2:12 AMLIMIT x
support that I know of - instead, you need to add WHERE rownum <= x
tdietrich
07/17/2020, 2:22 AMSELECT DISTINCT Type FROM Transaction
returns an "INVALID_PARAMETER" error ("Invalid search query Search error occurred: Invalid or unsupported search.").Clay Roper
07/17/2020, 2:27 AMN/query
in Suitescript or the Connect Service?Clay Roper
07/17/2020, 2:29 AMtdietrich
07/17/2020, 2:29 AMtdietrich
07/17/2020, 2:32 AMSELECT Transaction.Status FROM Transaction GROUP BY Transaction.Status
which works, but just feels... wrong.Clay Roper
07/17/2020, 2:32 AMquery.runSuiteQL()
dozens of times a day, and I often run a version of SELECT DISTINCT type FROM transaction
to probe for column details with no issue. I just ran that exact query and got the results I expected. I wonder if there's a difference under the hood in terms of implementation between queries run via SuiteTalk and N/query, but I can't imagine why that would be. There are plenty of odd differences between the various data models / schemas available depending on whether you're using ODBC vs saved search vs N/query, so I can't count anything out...tdietrich
07/17/2020, 2:33 AMtdietrich
07/17/2020, 2:35 AMtdietrich
07/17/2020, 2:36 AMClay Roper
07/17/2020, 2:37 AMSELECT id, status
FROM transaction
WHERE type = 'Opprtnty' AND
status NOT IN ('C', 'D')
because I'll get back results that include status of 'C' and 'D'.
Instead, I need to include the type in the WHERE clause like
SELECT id, status
FROM transaction
WHERE type = 'Opprtnty' AND
status NOT IN (type||'C', type||'D')
even though the status column only returns the letter (A, B, C,...)tdietrich
07/17/2020, 2:39 AMClay Roper
07/17/2020, 2:44 AMtdietrich
07/17/2020, 2:47 AMClay Roper
07/17/2020, 2:51 AMjen
07/17/2020, 4:21 AMstalbert
07/17/2020, 4:23 AMtdietrich
07/17/2020, 10:30 AMSELECT time_id, product, LAST_VALUE(quantity IGNORE NULLS) OVER (PARTITION BY product ORDER BY time_id) quantity FROM...
tdietrich
07/17/2020, 10:38 AMjen
07/17/2020, 4:19 PMjen
07/17/2020, 4:19 PMtdietrich
07/17/2020, 4:43 PMjen
07/17/2020, 5:48 PMjen
07/17/2020, 5:54 PMClay Roper
07/17/2020, 7:32 PMIGNORE NULLS
issue?jen
07/17/2020, 7:38 PMjen
07/17/2020, 7:39 PMClay Roper
07/17/2020, 7:42 PMLAST_VALUE
with FIRST_VALUE
including IGNORE NULLS
and since the first value was a null, I got an entire column of nulls. Nothing about that seems right 😄jen
07/17/2020, 8:49 PMjen
07/17/2020, 8:50 PMjen
07/17/2020, 8:50 PMClay Roper
07/17/2020, 9:34 PMNVL(loc.id,LAG(loc.id,x) OVER (ORDER by tx.id, tl.linesequencenumber))
- the key is to make the lag amount (x
) dynamic so that it's able to pull from the last non-null row. You might be able to leverage ROW_NUMBER()
somehow, or otherwise accumulate a count of contiguous null
rows to get that offset.jen
07/17/2020, 11:34 PMClay Roper
07/18/2020, 1:02 AM