How can i order the results in my select query to have them like this? I tried this query but the result is not what I’m looking for: In which col1 represents the first number, col2 is the second one and col3 is the last number in the above example. This query returns: Thanks Answer Sort should be 1-3-2…
Tag: sql
MySQL Difficult Where Clause
I need help with a difficult query which I may not explain well with words. The query needs to only return results where all the characters in the code column are in the where clause. Say I had the following table and wanted to return the code and position where ABC. Table: code position ABC 100 ABCD 200 ABCD…
Select from one table if present,else select from another having latest date
There are Three tables T1 and T2 and T3 T3 stores person details T1 stores primary phone number of person, T2 stores non primary phone number of persons. T1 Personid Primaryphone dateload 1 1001 02/08/21 2 1002 03/07/21 4 1004 04/08/20 5 1005 08/09/20 T2 Personid NonPrimphone dateload 1 1011 12/03/21 3 1003 2…
PostgreSQL get results in current time zone
as said in the title I would like to have a query that returns the value of the time stamp in my current time zone (even according summer time!). my_table is: (Don’t ask me why I cannot put this table directly in markdown…prob cause the dates) Now for example if I have to select the 24h correspond…
Why Synapse is not working with my query?
I’m trying to use a query in Synapse Analytics from Azure, and when I use it I got the next error: at Source ‘AgenciesInventoryQueryFromSynapsestg’: shaded.msdataflow.com.microsoft.sqlserver.jdbc.SQLServerException: Parse error at line: 1, column: 47: Incorrect syntax near ‘WITH’…
Trying to select data and then do a average on the selected data in mariadb
SELECT counts FROM (SELECT COUNT(ch_id) AS counts FROM tbl_warrants_checked WHERE status = “active” GROUP BY dateChecked); Answer This uses MariaDB 10.5, but should work with any version since ~10.2.2. If we assume every day has data, or we don’t care about the days which have no data, the f…
ID primary key of ONE to MANY related tables jumping numbers with POSTGRESQL
I am having an issue where the id column of tables users and posts are jumping in increments users and have many notes ==> one to many relationship table users table notes what is happening is the id column of the two tables jump…if there is 3 in id of notes, then next if for users will be 4 how
Getting an error using EXISTS operator but correct result with IN operator in
I am getting an error An expression of non-Boolean type specified in a context where a condition is expected while using EXISTS But when I am using IN operator it is giving the correct result. Below is enter image description hereboth query Answer EXISTS is a unary operator, not a binary operator, and takes o…
Show one table that is linked by value to another
I am new to SQL and some points are difficult for me to understand. I have 2 tables: Departments Lectors Departments.head_of_department refers to Lectors.id I need to display lector who is head of department in Department with name X. If it’s possible to select ALL table Lectors and ONLY table Lectors w…
Why did the ‘NOT IN’ work but not the ‘NOT EXISTS’?
I’ve been trying to improve my SQL and was playing around with a ‘NOT EXISTS’ function. I needed to find the names of salespeople who did not have any sales to company ‘RED’. I tried this and it did not work: This query ran but returned a NULL. Then I changed it to this and it wo…