Skip to content

Tag: sql

Case When syntax expression in jooq

I am trying to reproduce this MySQL query in jooq to Answer What you seem to be looking for is the SQL:2003 simple CASE expression, which allows to form something like “partial predicates” based on the case value, akin to pattern matching in other languages. This is not yet supported in jOOQ, see …

Making dynamic SQL queries to a MySQL DB

I’ve never used golang with mysql before, so I’m reading about these for the first time. I’d like to do something like this: This is far too much typing, especially if I have a dozen more variables I’d like to add to the WHERE condition. If this were PHP, I’d do something like th…

SQL Insert Into New Table from Old Table

I’ve got two table which are near identical, the only difference is the newer one has different field names. Basically the old table was outdated and needed to be re-worked; I’m trying to extract all the field where the VendorNumber = Vendor_ID all the field that are being copied to are guaranteed…

Concatenate with string but exclude when null

Oracle v11 Exclude a string in a Concat when the value is NULL? Work Query: TableA Output I’m getting Expected Output: Answer Something like this… I added simulated inputs to test all four possibilities. However, note that if you may have last name but no first name, and also first name but no las…

How to find duplicate rows in Hive?

I want to find duplicate rows from one of the Hive table for which I was given two approaches. First approach is to use following two queries: second query is as below which will give count of distinct rows With this approach, for one of my table total row count derived using first query is 3500 and second qu…