I have table like this I create get function like this I tried to call function like this but return json all 3 row instead of 1 row with booking_id 1467 can you explain root cause ? Answer The root cause of you problem is naming your parameter (booking_id) the same as a column name (booking_id) in your table…
Using JSON_VALUE for parse column in SQL Server table
I have never worked with JSON in SQL Server before that’s why need some help. I have written a simple snippet of code: In sample above I write code how get first “id” from “tags”. But how looks like script if in “tags” not 2 “id”, but an unknown number thi…
Finding latest timestamp per value across columns and rows
I have a database table with rows like Where ID is the non-unique identifier for the rows and will be used to filter the initial dataset. Fields s1 to s6 contain values and columns ts1 to ts6 contain their timestamps. And I need to find the latest (or first) timestamp per “s” value. The “s&#…
Need guidance on MySQL Query
I am having a table with values like this below one. Col1 Col2 Col3 Col4 col5 1 John ABC 10 20 1 John AED 52 15 1 John ABC 12 10 1 John AED 20 5 1 John ABC 10 5 2 Mark DDD 42 8 2 Mark BBB 10 5 3 Ben EEE 8 2 3 Ben FFF 1
Rounding time to aggregate entries close in time
I am trying to sum together content_len that are entered into the database a few seconds apart (colour coded). The table currently breaks into a new row once the character count hits 999, and inserts each overflow a few seconds apart. Due to errors, the overflow can be timestamped earlier than the previous bo…
Powershell mail every user from SQL query
Unfortunately, I could not find my answer from all the examples I came across. I have a SQL query that contains the following values First name Suffix Last Name Email address Now I want to send a mail per record and in the mail mention the name. Below is the code that doesn’t do the loop right now and p…
Table “already exists” after dropping with if exists
I got a pretty complex SQL that finally forced me to use a temp table to work around. Essentially it looks like this: However, I get an error message saying an object with the name #MYTEMPTABLE already exists in the database after a call with an error (which is rather likely if the customer/tester screws up s…
Assign min value or max value based on a value change
HAVE WANT (Get min date when ct_val within the ID group is 0 across that ID group OR get max date within the ID group where ct_val is not 0 (that is it may contain a 1) across that ID group). For instance, if the ct_val within an ID group is 1, pick the maximum dt where ct_val within that
How to combine records start date and end date in SQL
I have a set of data example below: ID Role START_DATE END_DATE 1 A 2022-02-01 2022-02-03 1 A 2022-02-03 2022-02-10 1 A 2022-02-10 9000-12-31 2 B 2022-02-01 2022-02-03 2 A 2022-02-03 2022-02-04 2 B 2022-02-04 2022-02-11 I want to group them based on the ID, ROLE, START_DATE and END_DATE. So it looks like belo…
Like in dynamic function
The code below works well. I however have issues trying to turn it into a like statement that I need some assistance with So far, I have tried the code below but with not much success I have also tried; Answer If your stored procedure parameter is @deliverer and your dynamic SQL parameter is @pt, I believe yo…