I have a table called contacts and in that table there is a field called contact_type. contact_type is varchar and stores comma separated values in a sting like this: ^Media^,^Historical^ However …
Tag: sql
Returning the row with the most recent timestamp from each group
I have a table (Postgres 9.3) defined as follows: The pertinent details here are the customer_id, the timestamp, and the licensekeys_checksum. There can be multiple entries with the same customer_id, some of those may have matching licensekey_checksum entries, and some may be different. There will never be ro…
Sql Server select datetime without seconds
I have datetime column value below I tried below and These are did not work for me How can i get above datetime as 01-04.2015 20:37 ? Answer In SQL Server this will work:
MySQL – Find the largest time difference between consecutive datetimes
I have a table that contains a list of datetimes. I’d like to find the longest amount of time between consecutive datetimes ie., find the largest distance between any two datetime entries that fall …
Is there any function in C# like isnull in SQL?
In SQL server we can use “isnull” function for example if Table1 Contains Field1 and only one record which Field1 is null we can write this Query: which returns “0”. can we use any function like this in C#? for Example Consider textBox1 is Empty. and I want to Show “0”. Ans…
SQL – Get result of current year only
How can I get the result of the current year using SQL? I have a table that has a column date with the format yyyy-mm-dd. Now, I want to do select query that only returns the current year result. The pseudo code should be like: The result should be as following: How can I do this? Answer Use YEAR() to
How to use substring and charindex in google query language
I have a google spreadsheet sheet with several columns: A: date B: string C: number … G: string (could be empty) H: string (could be empty) I would like to have a small table with the following: Get the sum of C in table, where rows are the values of G (substring of it, as they are configured as this:
SQL GetDate() returns wrong time
I am having an issue while using GetDate(), for some reason is not returning the right time (it is 7 hours ahead from the actual time) I am using AZURE and the Database is configured with the right location (West US). I will appreciate any help! I tried to run this script: Answer Azure SQL Databases are alway…
HANA: Split string?
Is there a way to split a string in HANA? Something similar to the equivalent in SQL Server: SELECT * FROM dbo.fnSplitString(‘valueA,valueB’, ‘,’)
MySQL monthly Sale of last 12 months including months with no Sale
This query displaying result for only existing month. I need all 12 months sales. Output: Required Output: Answer Thanks for @pankaj hint, Here i resolved it via this query…