Skip to content

Rails Nested SQL Queries

I have a database model Position(lat,lon) which holds latitudes and longitudes. I have a controller action called show_close_by which recieves a position in degrees (my_lat, my_lon), a tolerance (in …

How to write an “exclusive” query in SQL?

I am going over a past paper for a database course I am taking and I am stuck on an SQL question Here is the schema provided Country(name, capital, area), name is the key People(country, population, children, adult) where country refers to the name in Country, population is the total population, and children …

How to sort values in columns and update table?

I’m completely new to sql and can’t do that myself. So I need your help. I want to sort values in column and then save changes. But I don’t know how to do that. Table looks like that: Id | Name | …

Why am I getting duplicate results in my query?

I am using the Moodle database to query the latest forum posts made by students and teachers for the relevant course they are enrolled in. Here are the tables I need to join and an explanation in …

Oracle: transpose table

I’ve got the following query SELECT 1, 2 FROM DUAL AND I’d like something like SELECT TRANSPOSE(SELECT 1, 2 FROM DUAL) Which outputs the same as SELECT 1 FROM DUAL UNION SELECT 2 FROM DUAL I’d like …

Set an empty DateTime variable

I would declare an empty String variable like this: string myString = string.Empty; Is there an equivalent for a ‘DateTime’ variable ? Update : The problem is I use this ‘DateTime’ as a …