I have a query: That returns records such as these: I want to be able to only return records that only have ‘I’ values under Inv_Disp where the Order_Num may or may not be the same. But where if an Order_Num Inv_Disp contains an ‘I’ AND some other value such as ‘CH’ or R…
Tag: sql
Using SQL code, i need to create a string that automatically creates the dates between to seperate days
I am creating an automatically updating dashboard for repeating purposes and I need to automatically draw invoice values from our system between certain dates i.e. on Tuesday, the reporting needs to show Mondays invoices. Is it possible to create a string whereby dates are automatically set. So far I have rea…
Exclude ALL rows where the ids are the same, BUT one of the rows with the same ids meets the criteria and other doesn’t
How do I filter out ALL rows where the ids are the same, BUT one of the rows with the same ids meets the criteria and other doesn’t? Current Code: Answer You can try to use aggregate window function, writing your condition which you want to exclude. then filter them. Query 1: Results: If your column id_…
how to convert ulong to rowversion
reference to converting sql server rowversion to long or ulong? i can convert SQL RowVersion to ulong by code: Now, I am faced with a problem, how to convert ulong to byte [8]? I save the value of rowversion to a file, then read it and use it to make the query. the query parameter should be byte[] , not
Updating a column across the table going in loop, how do avoid?
Below update statement is running in a loop, how do i avoid this? I have 86Million rows in the table Table Data as below Desired table should be Thank you, Yum Answer Assuming that your query runs, you seem to need a where clause. I would speculate: Note that I removed gw from the group by. It is used as
SUM with Multiple Conditions
I’m writing a query on SQL Server and have hit a wall on cumulative sum with multiple conditions. I need to sum all the purchases in a day made by a user, I can do it separately, sum purchases by day(Daily_Total), or sum purchases by user(User_Total), but I run into a wall when I need both conditions me…
identifier ‘NEW.CITY_POPULATION’ must be declared
I am trying to declare a oracle trigger that will update the city name when the city population reaches 0 but I am getting this error. Answer If you’re going to reference the :new pseudo-record in a trigger body, it needs to be prefixed with a colon. A trigger on cities generally cannot query the cities…
Select rows where the title contains any term from a list
I have a datset that has product_id, product_url, email, product_title, etc. I want to pull rows where product_title contains certain adjectives (Fabulous, Stunning, Rare, Amazing, Unique, etc etc. ) from a list of 400+ words. How do I do this without doing a separate select function for each word? I am using…
How to insert a inner join from 3 different tables
I am making a view pulling data from 3 different tables for the query. Here is my code so far, I’m just not sure how to integrate the inner joins since I already have a select statement, I can’t …
Compare 3 SQL Server tables and once matched based on some attribute put the result on one table when not matched put the result in another
I have the simple requirement, there are the 3 SQL Server tables like this: Table 1; columns Table 2; columns Table 3; columns I wish to join (inner joins) based on Name, DOB, Gender & PostCode across all the tables, if the record matches I would like to put the result in one table and the remaining recor…