Skip to content
Advertisement

cast numbers and decimals into INT

I have [funds] that have been presented in different formats, some are decimals, others numbers: etc I tried to use this: ,CAST (REPLACE ([funds],’.’,”) AS INT) AS [funds] but got this mistake: The conversion of the varchar value ‘288294130100’ overflowed an int column. How do I ned to treat the combo of numbers and decimals? Answer You can cast them

Re-aligning dataset so that different period appear on the same row

I have each entity data over three different [periods]. These are: 2022-03-31, 2021-09-30 and 2021-03-31 I want to alter the dataset and have This can as such easily done by case statements. The problem is, I want that data to be aligned, so that [entity] appears and then on the same line [curr_period], [prev_period], [prev2_period] How can this be achieved?

Incorrect syntax near ‘<' in SQL Server Scalar Functions

Here is the requirement: Find all teachers whose FirstName length is less than 5 and the first 3 characters of their FirstName and LastName are the same I tried this query (Scalar Function): To call function: But, when I execute first query, it shows error: Incorrect syntax near ‘<‘. Can anyone help me with this? Answer Just use a normal

Find all ancestors without direct id-parentid in same table

I have a parent-child structure across two tables. The first table has BOM_ID for bills and ITEM_ID for associated children items. The other has BOM_ID and ITEM_ID for the parent item. I am able to find the first level of parents’ ITEM_ID with the following query So, in order to find all ancestors, I would have to repeat this step.

Performing division with PostgreSQL / json

I have written a simple query against a table in a Postgres database that contains a column “manifest” of type json. Each cell contains a very long value and I am extracting the numerical value for “size”. I need to create a new column (perhaps call it “size in MB”), and perform division against size. Specifically, I need to take

Determine what rows are causing error in query

I have an Oracle 18c table that has 15,000 rows. As a test, I’m trying to run the following query on it: When I run that query in SQL Developer, it initially runs without errors, but that’s just because it’s only selecting the first 50 rows. If I try to run the query on all rows (via CTRL+END), then it

How can I find all Sites with latest date?

I am trying to add all areas of data that will show all latest pricing. Because there are two latest dates for specific locations, only 5/6 show up with a date of 5/27. I need one location to show up as well as the latest date for it is 5/26. EXAMPLE BELOW: I currently have this query: RESULTS: I need

176. Second Highest Salary

The above-stated query is not working and giving a response as You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘having salary <> max(salary)’ at line 2 As having is used for aggregator functions this should work IMO. Please help me out by explaining

Advertisement