I am trying to updated IDs in a table named Price, based on matches of IDs in a table named CW. Here is the SQL that I’m testing. UPDATE Price SET ISN = (case when CW.id_cd = ‘ISN’ THEN CW….
Tag: sql
Language issues when running SQL statements from installshield
I have an installshield installation that connects to a SQL Server instance and inserts words from different languages. After the import runs When I query the data from the database characters from …
Not return row from table when use the case when condition
I have a basic question. I want to return data from my table when the condition is true but when it is not I got the null row, but I don’t want that. This is my example: select case when coalesce(…
SQL (Persons share the same birthday but they are exactly 100 years older or younger)
i have this table: How do I fetch a list of Persons who have the same dob and exactly 100 years older or younger? Expected rows: The difference between dob should be 100 years Answer If the DOB is a date data type, would suggest using TRUNC and ADD_MONTHS.
Custom SQL for quarter count starting from previous month
I need to create a custom quarter calculator to start always from previous month no matter month, year we are at and count back to get quarter. Previous year wuarters are to be numbered 5, 6 etc So the goal is to move quarter grouping one month back. Assume we run query on December 11th, result should be: YEA…
NZ function in T-SQL where ValueIfNull is NOT specified
I am working on an MS Access to SQL Server Migration project and am currently in the process of converting a complex query into T-SQL from MS Access. Now I’m quite familiar with how Nz works in Access …
TRIGGER that checks if that delete removes all the table values
Basicly I just don’t wanna allow that DELETE FROM X delete ALL rows. For example: DELETE FROM X WHERE ID = 3 OR ID = 4; –> Allowed because don’t try to remove all table. DELETE FROM X; –> Not …
This script won’t run on PHPmyadmin. Neither will any others [closed]
Closed. This question is not reproducible or was caused by typos. 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 trying to run this script or any script on PHPmyadmin, it shows …
Oracle – Selecting record based on latest date
In this query, in the ODF_CA_NL_INIT_REQ_NOTE n table, there can be multiple NL_NOTEs per each record in the ODF_CA_OTHER o table. One to many relationship. I want to select the n.NL_NOTE for each …
How can I convert an EAV schema to a normal schema using PIVOT?
I have a table called SourceTable, in that I have 4 fields. Properties_title field it has got 3 values (AAA,BBB,CCC) but can also have more. Depending on each of them, NumericValue field and Property_item_title field has a value.According to the table in the below, if Properties_title be AAA or CCC so Propert…