I have column user_orders we are storing like [1][2][3][5] // Expected output 1,2,3,5 [25][27] // Expected output 25,27 [2] // Expected output 2 I don’t understand why my master …
Tag: sql
Combine queries to show one set of results
I have two separate queries where I need to match up and combine together based on a date value. select convert(varchar,Delivery_Date,101) as ‘Date’, sum(case when billing_group = ‘3’ and …
SQL: Update all rows except one of each group
I have a table like this. Column “Mail sent” has either the values “0” or a date. +————-+—————–+————+ | Ordernumber | Email | Mail sent | +————-+———…
How to use sql statement in django?
I want to get the latest date from my database. Here is my sql statement. It works in my database. But how can I use it in django? I tried these codes but it return error. These code are in views.py. Version 1: Error: Version 2: Error: I’ve defined reg_date at beginning of the class. What should I do for
Do I need both conditions in IIf function?
I know the syntax of the IIf function in SQL is IIf(Boolean_Expression, True_Value, False_Value) But I just found a SQL Code where is written IIf([DATE_USER_TO_SPECIALIST] Is Not Null, Year([…
Rotate rows into columns with column names not coming from the row
I’ve looked at some answers but none of them seem to be applicable to me. Basically I have this result set: I just want to convert this to I know I should probably use PIVOT. But the syntax is just not clear to me. The order numbers are always two. To make things clearer Answer And if you want to
SQL Server Transpose FieldValue as FieldName
SQL Server Transpose , FieldValues as FieldNames: Hello All, I have a tricky request for all of you. I have a table with the following data Field1 Field2 Field3 Field4 ——-…
Problem with field not equal to null in case statement
So I have EXISTS in huge query which looks like this: EXISTS( SELECT * FROM ExistTable WHERE ExTableFieldA = @SomeGuid AND ExTableFieldB = MainTableFieldB AND …
Return boolean if duplicates exist
How do I return True if a table has any duplicate records and False if it has none. I don’t need a count, I don’t need to know which rows, all I want to know is if this table has duplicates or …
MySQL – surrounding precomputed variable with single-quotes prior to inserting
The primary key of my table is a char of fixed length 11. I have precomputed the key in my script, just like this: SET pes = LPAD(person_number, 11, ‘0’); Now, my variable meets my critera. It only …