I have two tables like so: tblOrders: OrderNo (pk), CurrentStepNo (fk) tblSteps: StepNo (pk), OrderNo (fk), StepName, StepType, StepStart, StepStop tblOrders contains tons of information about our …
Tag: sql
Get the max date time in a table with multiple entries for each date
I have a table that has Location | IsBroken | Date AZ 1 2019-01-01 12:00 CA 0 2019-01-01 12:00 NY 1 2019-01-01 12:00 AZ 1 2019-01-…
Oracle SQL adding additional foreign keys
I am creating a logical model on Oracle SQL, however am having a bit of trouble. When I add a relationship between two entities, I’d expect Oracle to add the PK of the parent entity to the child …
How to use prxmatch or alternative for below string in sas
I have multiple rows of strings I want remove and create new column with 25% and 20% and so on… From above string. How can I do that in SAS? The new column should flow 25% i.e percentage. So on…. Answer A single percentage value (or none) can be retrieved from a string using a pattern with a group…
SQL Table Valued Function – Return certain data from ‘WITH’ based on parameter value
I am trying to do a “with” to loop through some data (which its doing fine). But after that with, I want to return data dependent on a bit parameter. Its important that this is inside a function. …
Set some default guid value in uniqueidentifier in sql
I need to set default guid value, not NEWID() in uniqueidentifier column in SQL. For example: Have a column TestID in TestTable, need to set default TestID to “DA74F684-B228-48D5-9692-69465BE6D720”. Thank you in advance. Answer Here’s your script. then, update exsting records
How can I get the information from one field in a query to use in another query?
I am still trying to finish fixing my details page and I need one more piece to fix it. I start with this query. NOTE:recordID actually comes in from the previous page by clicking an item. Also, name, img, item_code, and type_id are fields in my table not outside sources. Now, I have created this to determine…
SQL – get distinct values and its frequency count of occurring in a group
I have a table data as: The data set is as follows: I need to list all distinct search_product_result values and count frequencies of these values occurring in s_product_id. Required Output result-set: Here, A occurs in three s_product_id : 0, 1, 2, B in two : 0, 2, and so on. D occurred twice in the same gro…
How to convert a query into a nested query
How do I change this query into a nested query? The query and tables are listed below. tables goes as follows Nation : N_NATIONKEY, N_NAME Supplier : S_SUPPKEY, S_NAME, S_NATIONKEY Customer : C_CUSTKEY, C_NAME, C_NATIONKEY Orders: O_ORDERKEY, O_CUSTKEY Lineitem: L_ORDERKEY, L_SUPPKEY, L_QUANTITY, L_EXTENDEDPR…
optimization select distinct query
How can i optimize this query, how to rewrite a request through exists: Answer Please use ANSI style join syntax, first of all. Now, Coming to your question, according to my knowledge NVL perform worse when working with large data sets. So how can we achieve the same functionality? — We can use DECODE o…