SELECT a.IDENTIFIER, a.NAME, a.CATEGORY, b.IDENTIFIER_TYPE, b.NAME, CASE WHEN b.IDENTIFIER_TYPE = 111 THEN ‘PRESENT’ ELSE ‘NOT PRESENT’ END AS HAS111 FROM …
Tag: sql
How to put Case in Where Statement for Oracle SQL
For the query below, I’m trying to pull a specific date range depending on the current day of the month. If it’s the 20th or less (e.g. “2/7/2020”) then I want the date range for January. Otherwise, I …
How to use aggregate functions in SQL Server
I have a situation where I have a Customer table and I need to locate document numbers from a column which is structured as a string where the first 4 characters represent the type of document (e.g.,’…
How can I query the list of IDs with conditions on couple of fields?
I have the following two tables: Table A ID Code1 Code2 ————– 1 2000 1 2 3000 2 3 1000 3 4 2100 1 5 3500 5 Table B Code1 Code2 ———– 2100 7 2100 1 3000 2 1000 4 I need to …
How can I return desired record when using pivot
I am using a pivot table to return records that have been updated in the past 7 days. If account has been updated, only return contype ‘AAA’ and ‘BBB’ for the ID. Each ID can have up to 8 ‘types’. I …
Is insert.addBatch() accessible outside of this for loop?
I have multiple for loops where I am setting the values to be inserted into a MySQL DB. My question is will insert.addBatch(); detect the insert values if it is outside of the for loop. Below is an …
SQL How would I show a rolling 3 month average for this query
Need some help with maths side of things with this bit of code. You may see I need help on even more! But any help you could give me would be great Basically, my aim is to bring back an; – AccountID,…
C# Error : Unable to insert record in SQL
Please pardon my knowledge on C# as I am very new to it,I am unable to insert a record in SQL and getting the below error while insert image to SQL. Error : Object reference not set to an instance …
SQL CASE statement needs to handle Text
Apologies if this has been asked before – I’ve spent a couple of hours searching but not found anything that’s helped. It’s quite simple really – I’ve been asked to create a query which includes a field that when it was set up (not by me) was created as a VARCHAR instead of…
How to select * from table but distinct on 1 column and order by on another column
I have a messages table with fields channel_number, body, created_at, recipeint_id & sender_id I want to have messages distinct on channel_number and order by messages.created_at basically I want …