I am struggling with a SQL request. I need to find a request to calculate the average loans per user. I was thinking in doing a LEFT OUTER JOIN between the table SUSCRIBER and the table Loan in order …
How to add/subtract n number of days from a custom date in postgresql?
I have a database in which, I have a issue_date column, and forecast_date column, I am selecting the maximum date from the database, but I want to fetch/query/extract the N th previous day from maximum available date like (maximum date – 1 / 2 or n number of days). & As the max date is custom, so can not use
How can I use a FULLTEXT query with MySQL to return all results matching a string?
This is the table videos: I currently have this query: I want that query to return all results with the string not in it but it is only returning 1 result instead of 2. What is the best way to get it to return all matching queries instead of only 1? Edit1: If I use the WITH QUERY EXPANSION modifier
One value for a group of columns in sql
I have the columns like this, all columns coming from three different tables. i want the columns like Can you help me with this? Thanks Answer i am just enhancing Tim answer by adding lag() window function DEMO
i cant view all data when i using Datepicker on ‘WHERE’
hy, please help me,, i cant view all data from emp0003 to checking all employee absence.. emp0003 table NIK Name 01190301 Susan 01190302 Jamed dvc0004 table’s NIK Enroll 01190301 2021-02-03 08:…
SQL Compare employees by gender in different departments
I need help to write a query that compares the number of male managers and the number of female managers in each department. tables are as follows. — Departments ————————— | dept_id …
How to grouping postgresql when id is same into new add value
I have table like this: And I would like to bring value item in one row when user_input_id and question_id is duplicate. The result that I wish is this: Can anyone tell me how to querying it? Thank You Answer You can easily do taht with string_agg(value,’,’) in postgresql. Output: You can also have array_aggr() in postgres: Output:
How to find which field is giving data type error in QUERY
I have the query report for user but have some error message display: Error converting data type nvarchar to bigint only one message. How to find which field is giving data type error in query? Anyone can give advice? Many thanks! Answer As you have not provided data, it looks like you have NVARCHAR datatype, which is not implicitly convertable
Finding top 10 products sold in a year
I have these tables below along with the definition. I want to find top 10 products sold in a year after finding counts and without using aggregation and in an optimized way. I want to know if aggregation is still needed or I can accomplish it without using aggregation. Below is the query. Can anyone suggest a better approach. Sample
How to get custom separators in SQL Server query
I have a table in SQL Server that looks like this If this table was in Oracle and I wanted to get all the properties separated by different separators then I would write something like this I would get output like this Notice all the separators are different. How can I write a similar select statement for SQL Server? Answer