Skip to content

Is this a perfect SQL query to fetch random items

I have this below query to fetch books of a random author and order by the books last modified date. Because I am new to SQL something tells me this query can be improved and simplified. I would appreciate the help of the SQL experts, if this is already simplified then I will consider myself an SQL expert :).…

Can I combine parts of multiple columns in Oracle SQL

I’m a student in college and I’m working on a project with Oracle DB. I was wondering if it was possible to make a column value appear as concatenated parts of other columns when I Insert a line and use that column as PK ? So on a table like this : So when I insert a line I’d like

MySQL join dataset on at least X items

My question in a SQL Fiddle. How can I join all elements in table A with all elements in table B via a many-to-many mapping table, even if no relationship exists? My LEFT JOIN solution isn’t giving the results I expect. Details: Given these tables: And this seed data: I need a report like this: The quer…

SQL pivot the column values

Problem Statement: Pivot the Occupation column in OCCUPATIONS so that each Name is sorted alphabetically and displayed underneath its corresponding Occupation. The output column headers should be Doctor, Professor, Singer, and Actor, respectively. Note: Print NULL when there are no more names corresponding to…

SQL UPDATE WHERE CASE

I know my SQL knowledge is weak. Unfortunately I found out I know less than I had perviously thought. I wrote an UPDATE command to use in a simple HTML settings page using a form. (There is some …

SQL: select the last values before a space in a string

I have a set of strings like this: I need to extract only the last values from the right and before the space, like: how will the select statement look like? I tried using the below statement, but it did not work. Answer Perhaps the simplest method in SQL Server is: This is perhaps not the most performant met…