I know I could probably just count the commas but I wanted to know if theres a built in way to count the results in a comma seperated list? e.g DECLARE @IDs NVARCHAR(100) SET @IDS = ‘2,3,54,234,’ …
Using regex in Oracle sql
I want to extract 2 parts of certain string. For this I want to use regular expressions. For Example the String is: Big_Dog_0044_0080 and my Regex is: Big_Dog_([0-9]+)_?([0-9A-Z]*) Group 1 would be …
T-SQL :: generate random Swiss National Identification Number (AHV/AVS)
I woul like to generate random Swiss National Identification Number (AHV/AVS). I found a website that can do that and if I look at the source code of the same page I can alos see the JavaScript code that can generate it. The numbers are generated following this pattern: 756: is the prefix number, it never cha…
Why SQL (On-Prem using Data Gateway) Insert row (V2) action in Logic App does not populate tables?
I have an On-Prem SQL which I am accessing in my Logic App using On-Prem Data Gateway. I have created a table in my SQL database as per below: From a Logic App, I am trying to insert rows using “Insert row (V2)” action but it does not populate any tables: If I try any other SQL action in a
How to get count(percentage) for columns after each groupby item?
I have the following table. Using sqlite DB Item Result A Pass B Pass A Fail B Fail I want to realize the above table as below using some query. Item Total Accept Reject A 2 1(50%) 1(50%) B 2 1(50%) 1(50%) How should I construct this query? Answer You can try PIVOT() if your DBMS supports. Then use CONCAT
count business days in calculation
Continuing from my previous question: case when date column is greater than sysdate then ‘Y’ One thing I forgot to consider was including working days in the calculation. Here is the query: So I need to exclude Saturday and Sunday in the calculation above. I tried to add this in the where clause: …
find the max for each value in SQL
i have tables like this table 1 table 2 i want to get the max value for each element in table1 from table2 and the different parameter so the expecited tabel should be like this Answer You can try to compute all the maximums: and then join them with the original Table2, e.g.
Selecting the maximum date before a certain year
I have a table where I’d like to select only the record with the maximum date: The issue is that I have some IDs in the table where the maximum date is in 2022, so that is what gets selected. How do I select the maximum date for a record that is before 01JAN2022 so that my output look like
Before/After Difference for a flexible Date (Case)
i have a little problem with a case. I output two date fields (yyyy-mm-dd). the date changes and is flexible. not every entry has the same date fields. I take one date field as an fixed point. If the Date is 4 months before the date, a ‘V’ should be the output. if it is behind it, an ‘N̵…
Validation trigger not working in SQL Server
I am working on a trigger for a class project. I have a table named salesman with a column named type. All employees in the table currently have a type of full, part or temp. The purpose of the trigger is to check a newly inserted row’s type and make sure that it matches one of the three that already