I want List of party names with 1st option as ‘All’ from database. but i won’t insert ‘All’ to Database, needs only retrieve time. so, I wrote this query. Select 0 PartyId, ‘All’ Name Union select …
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…
Difference between javax.sql and java.sql?
What is the difference between javax.sql and java.sql I understand that javax.sql is for JavaEE. or am I wrong. I am struggling with understanding this difference. And their usage scenarios.
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…
sql query distinct with Row_Number
I am fighting with the distinct keyword in sql. I just want to display all row numbers of unique (distinct) values in a column & so I tried: however the below code giving me the distinct values: but when tried it with Row_Number. then it is not working. Answer Use this: and put the “output” of…
Fastest way to determine if record exists
As the title suggests… I’m trying to figure out the fastest way with the least overhead to determine if a record exists in a table or not. Sample query: Say the ? is swapped with ‘TB100’… both the first and second queries will return the exact same result (say… 1 for this c…