IT will gives error But when we use single where clause its working and my response is But my problem is based on queryParm as userId we get data not all, so i added multiple where claues we get error please help me for that. Answer So AS you look at the error message it obviously said that the parameter
Tag: sql
NetSuite Case statement works in Saved Search but doesn’t work in Workflow
I have an issue with a formula case statement in a NetSuite workflow, I am using the same case statement in a saved search and it works just fine, but generates an error in the workflow formula for sourcing date, to set the date field on a cashsale record created from a sales order. NetSuite formula which bas…
Efficient way to join multiple columns to the same column? – SQL
I have a bunch of tables combined together, which each have a column containing some form of user_id. This leads to 12 user_id columns in total. I want to join each of these user_id columns with a user_id column in a mapping table in order to retrieve the username for each of these user ids. So (assuming I ha…
Fill NULL and get distinct record
I am ingesting data from two different source (source A and source B). Although data may be coming from two different sources, there is a possibility that an ID for a record may exist in both sources. The problem is, there are cases when one source is more complete than the other. In the example below, Source…
Union All with Join
I’m trying to perform a join after Union All. Separately the 2 queries work but I haven’t been able to piece together the join. The Unioned query needs to then be joing by assigned_user_id from the accounts table join Answer You need to make them subqueries, like this: I personally don’t lik…
SQL Query: finding cheapest car by company
Following YouTube tutorial “Learn PostgreSQL Tutorial – Full Course for Beginners”, I replicate teacher’s code but yields different result and cannot figure out why. Table is this simple: and so on, 1000 entries. Querying cheapest model from manufacturer, tutorial says: And it works pr…
Snowflake Scripting in SQL – how to iterate over the results of a SHOW command?
I’m checking out the new SQL Snowflake Scripting (in preview), and I can’t figure out how to iterate over the results of a SHOW command — especially as some columns are lower cased. https://docs.snowflake.com/en/developer-guide/snowflake-scripting/ https://hoffa.medium.com/sql-scripting-live-in-sn…
Update Table T1 column to be the quotient of two queries each leveraging ID from T1
I am trying to update a column to be the quotient of two queries that count records in two other tables for each ID in T1. It seems like this should work (but doesn’t): Edit to add data sample and expected output: T1 is like: ID COLUMN1 0 1 T2 and T3 are both like this, where ID can be
Insert data into a table from Open Query with variable
I am trying to using OPENQUERY to pull some data into a table. Here’s what my code looks like: I end up with the following error: An INSERT statement cannot contain a SELECT statement that assigns values to a variable. When I attempt to run the EXEC(@TSQL) without the INSERT it works like a charm, but I…
MIN() vs LEN() Behaviors as Shortest String
I’m trying to solve a question in HackerRank called “Your Weather Observation Station 5”, the question asks to return the shortest and longest city names within the provided table. Demonstration to clarify my confusion: SELECT MIN(City) FROM STATION; Output: A name of city with 4 characters.…