*I don’t get value of max in function other. Value return is “0”. I trying but not success 🙁 Image Help!!! Answer You’re not using it as it should be. First of all, you use AVG but want MAX so change it to MAX(GiaSP). Second, you must use rs.next() to have your cursor go to the first r…
Tag: sql
Why should I use EXISTS() function in MySQL?
I have this query: And when I remove that EXISTS() function, still my code works: So why should I write that? What’s its advantage? Answer In short: EXISTS returns when it finds the first result instead of fetching all matching records (so it is more efficient when there are multiple records matching th…
WITH in BigQuery
Does BigQuery support the WITH clause? I don’t like formatting too many subqueries. For example: WITH alias_1 AS (SELECT foo1 c FROM bar) , alias_2 AS (SELECT foo2 c FROM bar a, alias_1 b WHERE b.c =…
SQL several inner joins cause wrong SUM Result
An example of my Database: (SQLFiddle link at bottom) I have several Tables: Table Login User_ID (int) Email (varchar) Passwort Seassion ID Table Business ID_Login_ID_Business (int) …
error: there is no unique constraint matching given keys for referenced table “incident”
I know that this question has been already answered a million of times, but I couldn’t find any solution. Well I have these three tables on postgres sql. When I try to create the table incident_has_volunteer it throws the error there is no unique constraint matching given keys for referenced table ̶…
SQL using If Not Null on a Concatenation
If I have the table SELECT (Firstname || ‘-‘ || Middlename || ‘-‘ || Surname) AS example_column FROM example_table This will display Firstname-Middlename-Surname e.g. John–Smith Jane-Anne-Smith …
Spark SQL passing a variable
I have following Spark sql and I want to pass variable to it. How to do that? I tried following way. Answer You are almost there just missed s 🙂
Select certain column only if condition met
I want to have a select that will not have fixed number of columns. Column OptionalColumn should be selected only if variable @check = 1 This is what I had (syntax is bad but maybe it explains my problem) It is crucial to have it only if @Check = 1 and not having it if @Check = 0. Is it
MySQL: How to convert seconds to mm:ss format?
I want to convert seconds to minute : seconds format in sql select statement. At the moment I am using: It works perfectly but it gives me this format of time: hh:mm:ss but I need mm:ss Is it possible to convert seconds into mm:ss format using sql query? Answer If the value is less than an hour, then just do:
SQL Updating column after adding it giving “Invalid column name” error
I have the following SQL in SQL Server 2005 but I get an error stating “Invalid column name ‘ExpIsLocalTime’ (ln 7) when I run it: IF NOT EXISTS(SELECT * FROM sys.columns WHERE Name = N’…