Skip to content

Tag: sql

Oracle: SELECT value from where clause as dummy table

after a lot of searching I unfortunately couldn’t find a solution for the following task: I need an Oracle-SQL-Query that returns the value from the WHERE-clause as the result value. This sounds easy, but I just couldn’t find out how to achieve this. Example (how it should be): Desired Result: I k…

Postgres on conflict do update on composite primary keys

I have a table where a user answers to a question. The rules are that the user can answer to many questions or many users can answer one question BUT a user can answer to a particular question only once. If the user answers to the question again, it should simply replace the old one. Generally the on conflict…

Combining 2 queries in 1 (select based on other select)

I have 2 queries: and second one base on first one They work nice, but I need them to work as a one combined query, result from access looks like this: But this gives me only empty table. Can you help me? Answer Your inner join depends on the right-hand-side table of the left join, this effectively converts t…

Building complex SQL command

I am using sql for select, update, insert and some other features, but only simple ones until now. Now I need to write a complex command. I have looked at using case but I do not know how to implement it. This is what it should look like: I used ~TACNO~ to point out where I need a conditional value.

Getting all weeks data of a month using inner join

I have the following query: Above query explanation: I’m getting all weeks data PaidKM which driver gets in a whole month. The month for example starting date is 01-07-2018 and ending date is 31-07-2018 which covers whole month # 07. But when I change the month it gives me the same results all time. Abo…

Why did I sum the wrong result?

I’d like to have an advice for this SUM that doesn’t work as expected. I have to SUM data from the same day and display it in a table. I did a query like this: This is the ‘simple’ one and it displays every single row, I have to put a SUM in it to make it show every day

Multiple joins in SQL statement

To clear things up, I have two tables, employees and jobs. In employees I have columns firstname, lastname, employees id. In jobs I have columns job_id, job_name, job_description, job_opener, …