I have a simple question. If I have a week number, how I assigned a Sunday to it? (In t-sql) For example. I have number 15 as input (which is week from 8.4. to 14.4., from monday to sunday), and I will need it to be shown as 14.4. as output. The things is, that I have a column of
Tag: sql
Trying to filter null values in aliased column – postgresql?
have the following postgresql command: I would like to add in a where clause to filter out where the link value is not null – so it contains a value. when i run the following i get an error message: column link not found any ideas on how to solve this problem? Answer In a SQL SELECT query, the logical
Left Join return not all row
I have two tables: baseresulttables and historyviewdemands. I want to get the first n entries from baseresulttables, and if there are values for them in historyviewdemands. But the query works like an inner join. What am I doing wrong? baseresulttables historyviewdemands Query: reuslt Answer Using LIMIT witho…
compute SUM for 1st row and zero total duplicates
I have sql query that uses windows function and i manage to compute the sum of records from table 2 however I’m having trouble in removing the duplicate of total from table 1 and display the sum only in row 1. Query: Output: +———+———–+———-+R…
SQL between date range returning a wrong result
I’m writing a SQL query to get rows between a date range format: mm/dd/yyyy I used the between operator but the result shows out of the range dates The expected result : dates of year 2020 only The actual result is: Answer I assume that you use SQL Server. Maybe you think that % is a wildcard char in th…
How to select combination of 4 digits number from table columns?
I have a table as below:- id | columnA | columnB | columnC 1 7234 3432 3245 2 1237 1123 6546 3 4421 9371 7324 4 1244 1424 4237 How can I select …
PostgreSQL parse countries in array against the countries table
We have content and country tables. Country is pretty simple: country_name column defined as string: Albania, Belgium, China, Denmark etc… Content is a table with half a million of rows with various data with countries column defined as array text[]. Each value there has a number of countries concatenat…
I have 3 table and need exclusive left join
Table_1: Table_2: Table_3: Using 2 left joins I got this: But I do group over the first column and 8 is accumulated twice, I wish to get: I also wish to avoid UNION ALL because my first table is actually a complex query, I wish to avoid its recalculation. https://dbfiddle.uk/?rdbms=postgres_12&fiddle=d601…
how to get single result in using 2 table data
i have to table 2 in same structure .i already get the result by using one table using following query this query will time devide in to the 2 part(time in and time out) .it work fine.now want to get the data from anther table also.it also have same structure attendancedata table. attendancedata table structu…
i can’t Merge two tables
i have one tables attendance main table i created 2 views from attendance table attend view and leaved view view:attend view:leaved after that i used this code to merge attend and leaved view the result was like this result i need each employee has attend time and leaved time in same day Answer This following…