I am using SQL Server Always Encrypted feature of Azure SQL with .NET code. While it works like charm inside Entity Framework where the data can be decrypted, not sure how do I use it in stored procedures? Let’s say I have a column called Department Id and I have encrypted the same using Always Encrypte…
Tag: sql
Oracle: How to change column data type from VARCHAR to NUMBER without losing data
I have the following columns in my table: ID – NUMBER(10,0) NUMBER – VARCHAR(255) All data in the NUMBER column are numbers. I would like to change the VARCHAR type to Integer Number type. How to do it without data loss? Answer Oracle does not allow modification of data type of the column if it is…
Ruby Foreign Key Constraints in Database vs Model
I have the following models in a Rails app. This setup has worked fine since normally when I would like to add a new VendorPromo to a vendor, there’s a dropdown in the view of available Promos to choose from. Now, I’m enabling the creation of new VendorPromos via an API. However, this current set …
TSQL – Conditionally “Cross Join” Records
Code (staging sample data): Detail: @LookupTab is basically a filter that will have either 0, 1, or both values (111 – Option 1 and 112 – Option 2). @DataTab is the actual data in the table (can be huge). The Val field in this table can either be 111 (Option 1), 112 (Option 2), or 223 (Both Option…
DATEDIFF vs (w1.date = w2.date +1) difference? MySQL syntax
I was working on a SQL database question using MySQL. The goal is to find all IDs that satisfy today is warmer than yesterday. I’ll show you my original code, which passed 2 out of 3 test cases and then a revised code which satisfies all 3. What is the functional difference between these two? Is it a My…
Add missing monthly rows
I would like to list the missing date between two dates in a request for example My data : YEAR_MONTH | AMOUNT 202001 | 500 202001 | 600 201912 | 100 201910 | 200 201910 | …
PostgreSQL count of each status per day
I have the following table: I also have a table with every calendar day from 2019-11-01 to 2019-12-31. I need to find out how many occurrences of each status exist per calendar day for the time span listed above. If a status is Opened on 2019-12-14 and Pending on 2019-12-17, I need to count that it was Opened…
Oracle SQL data fetch order
I’m trying to achieve this Layout. I’m not sharing the query because it’s working, I’m just wondering what functions to use in order to achieve format ‘2’. In the beginning I was doing UNION ALL , that’s how I got format ‘1’. The data is fetched from multi…
Sql check range exist between a range
i have a table like and i have a range value for example i want to get row who’s value matchs the range from database table Example minV = 5 , maxV = 15 should return first and second record Example minV = 5 , maxV = 35 should return all record Example minV = 5 , maxV = 9
How to create group by age employee in php myqsl
I want to create chart.js for avarage age in my company. But I can’t create the query. SELECT DATEDIFF(CURRENT_DATE, STR_TO_DATE(t.employee_birthday, ‘%Y-%m-%d’))/365 AS `ageInYears` FROM `employee` …