Good day, I’ve got a column with text in my table, but i need to export words 17 letters long only in it. I tried to use but my query newer completes. This is an example of text cell REIGHT CAR DUMP T.M. “HOWO”, COMMERCIAL NAME A7, MODEL TOTAL 4 PIECES, WITHOUT PACKING IDENTIFICATION NUMBER …
Tag: sql-server
HIVE-SQL_SERVER: HadoopExecutionException: Not enough columns in this line
I have a hive table with the following structure and data: Table structure: Trying to push this data into the SQL Server. But while doing so, getting the following error message: What I tried: There’s an online article where the author has documented similar kind of issues. I tried to implement one of t…
How to retrieving data as customized format
I retrieved some data as below (image 01). i used this query: But I want that, like this type as below (image 02) Answer You can use conditional aggregation and window functions:
Check for condition in GROUP BY?
Take this example data: I need an SQL statement that will group all the data but bring back the current status. So for ID 1 the group by needs a condition that only returns the Completed row and also returned the pending rows for ID 2 and 3. I am not 100% how to write in the condition for this.
How to get weekending having all approved records?
I have a table like below now want to get weekending ‘3/1/2020’ since it have all 1’s in isApproved like this I want to get list of weekending having all 1’s in isApproved Answer You can use aggregation and filter with a having clause: This works because isapproved only has 0/1 values.…
How can I get values of the Rating column together with their definition for every specific month by using Pivot with Month in MSSQL
Example : Data: Query: I get this error: Incorrect syntax near ‘,’. In line with ” Definition, Rating ” Result should look like this: Is this possible? Any help, please! Thank you! *The code above was based on PIVOT with MONTH(). Answer You could just use conditional aggregation: This …
A constraint with function that contains Select is never satisfied
I have a table like this: And I need to forbid any rent time intersection for the same car. I found that, when a function is used (example below) inside the constraint, the value it returns is different from whent it is used outside the constraint. So when I’m trying to insert data into the table, the c…
Update records in table from CTE results
I want to update the records in my table using CTE. And I’ve been trying with the insert function using CTE and it’s working. This is my query with the insert function: How to change that with the update function? i want to change to update function because when i use insert function,the previous …
Three table join, subquery, or something easier?
I was wondering if someone could help me with this. This is a quick representation of a much more complicated schema. I am looking to get this implementation which is part of a larger stored proc. …
Sum last two records including last record of a group
In SQL Server 2017, how do I sum the last two records and show the last record in a single query? Expected output: I tried using SUM with LAST_VALUE with ORDER BY Answer You can filter out rows by using the ROW_NUMBER() window function, as in: See SQL Fiddle.