I’ve got the below piece of code in my query: CAST(COUNT(C.DateChanged) * 100.0 / COUNT(A.LastPassedBackToSalesDate) AS numeric(18, 2)) AS PBTSbutActived Both fields are of DateTime datatype. The …
Root level node is not coming in result
I am new to the Oracle Hierarchical Queries. I have one table and have the below data. Table Data Result Data My question is why parent id(100) is not included in the result? Below is the query. …
How can I get rid of having to prefix a WHERE query with ‘N’ for Unicode strings?
When searching for a string in our database where the column is of type nvarchar, specifying the ‘N’ prefix in the query nets some results. Leaving it out does not. I am trying the search for a …
Avoiding SQL Injections with Parameters by C#?
I have recently adjusted my code to avoid getting SQL injections for maria db and got helped with adding parameters ,when I using parameters method page got running time error I am relatively new to using maria db so any help is appreciated Answer If you want to avoid SQL injections, another approach besides …
How to get list of movies based on genre and language
I have stuck to get list of movies based on genre and language. Here’s my database structure: movies table ———————– id | title| ———————- 1 | ABC 2 | PQR 3 | MNC …
Derby – java.sql.SQLException: Column ‘table.column_name’ not found
I have these 2 tables: inventory and product_categories both tables have a common column called businessId. Now I have 2 databases, one is hosted on MySQL and the other on Derby both databases have same table structures. So I’ve been executing the following query on both databases: When I execute the qu…
How to pass a variable to a subselect in a view
I have a table of posts, post_likes, and I need a query that will give me both totals for likes for posts, and also a given specific user’s likes for those posts. This means I need a good way of …
How do I write a case statement to return duplicate records?
I have a table of names and addresses and want to return the full list of names and addresses with an extra column that identifies if the address is a duplicate or unique address. There are several duplicate address entries that I can see when I run a more simple statement — or but I need to return the …
Using SQL to select all possible set of rows using value of a column
I’m wondering if such thing is possible with SQL only. What I’m trying to achieve here is the following: An SQL table with the following column: ———— | DURATION | |———-| | 5 | | …
How to get the number of new subscriptions and the number of subscription renewals in SQL?
Having this table representing users subscriptions: CREATE TABLE `subscriptions` ( `id` int(11) NOT NULL, `email` varchar(255) DEFAULT NOT NULL, `created_at` datetime NOT NULL ); There can be …