I have a table with a column called Description. The column is populated with text data. I want to create a query that returns the amount of words in each description. My thought was to create a function that takes in a value, and returns the amount of words found in the inputted text. For example, if the des…
Tag: sql
How to round this in SQL
we just started our studying on SQL and I seem to have a slight problem with one exercise. I would need to round the result of I was trying to do it with subquery but I just did not hit the correct one even tough similar subqueries with only select seem to work well. Any help? Answer Use ROUND
Replace identity column from int to bigint
I am using SQL Server 2008, and I have a table that contains about 50 mill rows. That table contains a primary identity column of type int. I want to upgrade that column to be bigint. I need to know how to do that in a quick way that will not make my DB server unavailable, and will not delete
Decode equivalent in postgres
There is no equivalent to the Oracle’s DECODE()’Function InPostgres`. Is there anyone who wrote decode as a Function?
select users have more than one distinct records in mysql
For a table that holds the records of user’s webpages visiting behavior, how can I select users that visit more than one webpages. The structure of this tables is: userId webpageId …
how to execute a .sql script on heroku?
I have a .sql file with a bunch of insert commands that I want to execute on my postgres database on heroku. But I don’t know how to do it:- If I had access to postgres console I’d type the following: but it seems that heroku doesn’t support this command. I’ve tried with but that doesn…
MYSQL How do I Select all emails from a table but limit number of emails with the same domain
As the topic sugests I want to select all emails in the list. But limit the number of emails with the same domain. Lets say i have 500 gmail adressses. And 2 example.com adresses. .. and so on.. …
Django: Adding “NULLS LAST” to query
I would like to sort a model by using Postgresql’s “NULLS LAST” option. How could it be done? I tried something like MyModel.objects.all().extra(order_by=(‘-price’, ‘NULLS LAST’)) But I get “Cannot resolve keyword ‘NULLS LAST’ into field” Answe…
Filter Table Before Applying Left Join
I have 2 tables, I want to filter the 1 table before the 2 tables are joined together. Customer Table: Entry Table: I want to Left Join so I get all records from the Customer table regardless of whether there are related records in the Entry table. However I want to filter on category D in the entry table bef…
Export data from a non-normalized database
I need to export data from a non-normalized database where there are multiple columns to a new normalized database. One example is the Products table, which has 30 boolean columns (ValidSize1, ValidSize2 ecc…) and every record has a foreign key which points to a Sizes table where there are 30 columns wi…