For my application I have a topic table and a vote table. The vote options are -1, 0, and 1. I’m trying to find the amount of times each topic was voted -1 and 1. So to find out, I am doing many …
Tag: sql
How do I generate an array containing the numbers 1 to n in Postgres
I’m hoping there exists something like this: > SELECT nrange(10) {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} Similar to the range function in languages like Python and Racket. Of course, if no such function …
How to know if an uncommitted transaction tries to insert a specific unique key into SQL
I’m writing a programm which inserts data to a MariaDB-Server and can be used by different people on the same time. The transactions take some time, so the following problem might occur: Person A …
Array operation on hive collect_set
I am working on hive on large dataset, I have table with colum array and the content of the colum is as follows. [“20190302Prod4” “20190303Prod1” “20190303Prod4” “20190304Prod4” “20190305Prod3” “…
Generate range hours and range numbres SQL/HQL
I have a problem with a table.I currently have this empty hours table and I need to fill it automatically with a query in Hiveql. The idea is to generate: In the first column “key” values between 000000 and 235959 In the second column “hours” values between 00:00:00 and 23:59:59. Now m…
Export ER diagrams from SSMS
I have some ER diagrams created in the development server. I want to export this as PDF and share with my analyst for further usage. The diagram needs to be in PDF format alone since the analyst doesn’…
SQL Server query order by sequence serie
I am writing a query and I want it to do a order by a series. The first seven records should be ordered by 1,2,3,4,5,6 and 7. And then it should start all over. I have tried over partition, …
Converting string to integer and then converting back to string
I have some update statements like this: UPDATE tmp SET MyVarCharColumn1 = ISNULL(SomeOtherVarCharColumn,0) FROM #myTempTable tmp; Note that MyVarCharColumn1 is of type VarChar() but in real …
Merge update records in a final table
I have a user table in Hive of the form: User: Id String, Name String, Col1 String, UpdateTimestamp Timestamp I’m inserting data in this table from a file which has the following format: I/U,…
STRING_SPLIT in TSQL on MS Server creates list with repeating values. WHY?
I am using 2017 MS SQL Express. The following code creates this erroneous result. Any clues why? SELECT BNAME, LIC_STRING INTO dbo.SEPARATE2 FROM dbo.together CROSS APPLY STRING_SPLIT(LIC_STRING, ‘,’)…