How do I create a new table in Access without duplicates in the PROD_ID field based on a table that has duplicates in this field? I would like a table like this: Note: PROD_ID; ATC_COD_1 and ATC_COD_2 are the field names. Starting with table like this: Note: PROD_ID; ATC_COD are the field names. There always …
Tag: sql
SQL Find column with multiple possible values
I have two tables: TABLE 1 TABLE 2 I need the rows from Table 1 where i can have ALL values from table 2. The values from table 2 are dynamic, so i need to create a procedure to search for these possible values. My output should be in that example: Answer You can do this by doing a join
How to fix “Incorrect syntax near ‘)'”. when there is no ) in the query
I am attempting to run a query against my database using Dapper, however, an exception is being thrown. The message of the exception is Incorrect syntax near ‘)’ The part of this that is confusing to me is that I have no right parens in my entire query. It used to have some, but I have been simpli…
Find value that can be 0 or can be greater than 0 but must have at least one record equal 0
I need to find records that equal 0 and have other records that are greater than 0. The result should have at least one record that equals 0 and must also have at least one record that is greater than 0. It is easier to explain it with visuals: It should not look like: I have tried this: Sorry if
Inserting rows based on conditions
Table Name: CaseHistory I’m currently working with a dataset that aims to offer insights on customer support cases on a weekly basis. In the example above, you can see the progression of case 123376 from Week 1 till Week 5, amongst other cases. What I would like to be able to do is insert a row for a ca…
put a 1 if the customer has bought in 3 following months sql assistant
I’m a beginner with teradata SQL assistant and I don’t know if it can do what I need. I have a base with the variables ID, month (or period) and the incomes of that month. What I need is to put a 1 if …
Average price based on dates
I am trying to calculate a weekly average, and add it as a new column along side what I already have. I have added week starting dates and week ending dates as I thought that would be useful (and how I found do it in a more familiar MS Excel environment). This code returns a table with 4 columns. I
pyodbc.ProgrammingError: (‘The SQL contains 1 parameter markers, but 7 parameters were supplied’, ‘HY000’) [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 2 years ago. Improve this question When running the below script it ends in the following error, as I do find other posts o…
Date compare and difference
I have “Employee” table with employees’ “StartDate”. I want to get a list of all employees who are reaching their work anniversary next month. So far I have reached up to this point: …but this doesn’t seem to be working. Answer I want to get a list of all employees wh…
Finding voters that did not vote in an election through a many to many relationship with MySQL
I have two tables linked through a many-to-any relationship. Table one contains all voters with an ID, table two contains all elections with an ID, and table three links both tables using their IDs. …