name salary —– —– mohan 500 ram 1000 dinesh 5000 hareesh 6000 mallu 7500 manju 7500 praveen 10000 hari 10000 How would I find the nth-highest salary from the …
Tag: sql
How would I write SELECT TOP 25 sql query in Spring data repository
A quick question, because I am sure this is something silly. I have the following query which I can execute in NetBeans sql command window: My goal is to put put it in my ArcustRepository class: public interface ArcustRepository extends JpaRepository { However, that findBytop query doesn’t seem to work …
Stored procedure returns int instead of result set
I have a stored procedure that contains dynamic select. Something like this: In SSMS the stored procedure runs fine and shows result set. In C# using Entity Framework it shows returning an int instead of IEnumerable? Generated function for usp_GetTestRecords Answer Entity Framework can’t tell what your …
How do I get the query builder to output its raw SQL query as a string?
Given the following code: I want to get the raw SQL query string that the database query builder above will generate. In this example, it would be SELECT * FROM users. How do I do this? Answer To output to the screen the last queries ran you can use this: I believe the most recent queries will be at the
Sum columns depending on another column value
I’m having trouble with summing the fields values based on another fields value. I need to SUM(activities.points) based on activities.activity_type if it’s used_points or added_points and put it in AS used_points/added_points. Table activities: Table subscriptions: What I need: What I tried : Whic…
42501: INSUFFICIENT PRIVILEGE ERROR while querying in Postgresql
I am trying to query a database table in postgresql, but every time I run the below query it gives me the INSUFFICIENT PRIVILEGE error. What possibly could be the reason for such permission denied …
Count of non-null columns in each row
I have a table that contains 4 columns and in the 5th column I want to store the count of how many non-null columns there are out of the previous 4. For example: Where X is any value: Answer
MySQL select formatted date from millisecond field
I have a column in a MySQL database that contains a date as milliseconds (epoch). I want to build an SQL query that formats the date as something human readable (day, month, year, hours, minutes, …
Need to export SQL for creating table(s) from Enterprise Architect
I need to create SQL statements from Enterprise architect v.9 table description, since I need “CREATE TABLE” to be placed in a text file. Please advice me where to look in EA interface!
Test for Upper Case – T-Sql
All, How can I check if a specified varchar character or entire string is upper case in T-Sql? Ideally I’d like to write a function to test if a character is upper case, then I can later apply that to a generic varchar. It should return false for non alphabetic characters. I am only interested in englis…