Skip to content

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 …

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…

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 wo…

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…