The document contains a series of SQL queries that select data from authors and titles tables to retrieve author names and titles, count rows, calculate aggregates, and group and filter results. The queries join authors and titleauthor tables to titles to retrieve related data and filter on conditions.
The document contains a series of SQL queries that select data from authors and titles tables to retrieve author names and titles, count rows, calculate aggregates, and group and filter results. The queries join authors and titleauthor tables to titles to retrieve related data and filter on conditions.
The document contains a series of SQL queries that select data from authors and titles tables to retrieve author names and titles, count rows, calculate aggregates, and group and filter results. The queries join authors and titleauthor tables to titles to retrieve related data and filter on conditions.
The document contains a series of SQL queries that select data from authors and titles tables to retrieve author names and titles, count rows, calculate aggregates, and group and filter results. The queries join authors and titleauthor tables to titles to retrieve related data and filter on conditions.
FROM authors aut INNER JOIN titleauthor tit ON aut.au_id=tit.au_id INNER JOIN titles tits ON tits.title_id=tit.title_id WHERE tit.title_id LIKE 'B%' ORDER BY aut.au_lname
SELECT aut.au_lname, aut.au_fname, tits.title
FROM authors aut INNER JOIN titleauthor tit ON aut.au_id=tit.au_id INNER JOIN titles tits ON tits.title_id=tit.title_id ORDER BY aut.au_lname
FROM authors aut INNER JOIN titleauthor tit ON aut.au_id=tit.au_id INNER JOIN titles tits ON tits.title_id=tit.title_id WHERE tits.title LIKE '%data%' OR tits.title LIKE '%computer%' ORDER BY aut.au_lname
SELECT aut.au_lname, aut.au_fname, tits.title
FROM authors aut LEFT JOIN titleauthor tit ON aut.au_id=tit.au_id LEFT JOIN titles tits ON tits.title_id=tit.title_id WHERE tits.title is NULL ORDER BY aut.au_lname
SELECT aut.au_lname, aut.au_fname, tits.title
FROM authors aut RIGHT JOIN titleauthor tit ON aut.au_id=tit.au_id RIGHT JOIN titles tits ON tits.title_id=tit.title_id WHERE aut.au_lname is NULL OR aut.au_fname is NULL ORDER BY aut.au_lname
SELECT COUNT(*) FROM titles
SELECT COUNT(*) AS Total FROM titles
WHERE type='business'
SELECT MAX(ytd_sales) AS Máximo FROM titles
SELECT MIN(ytd_sales) AS Mínimo FROM titles
SELECT MAX(ytd_sales) AS Máximo,
MIN(ytd_sales) AS Mínimo, AVG(ytd_sales) AS Promedio, MAX(ytd_sales) - MIN(ytd_sales) AS Diferencia, MAX(ytd_sales) + MIN(ytd_sales) AS Suma FROM titles
SELECT COUNT(type) FROM titles
SELECT type, COUNT(type) as cantidad
FROM titles GROUP BY type
SELECT type, COUNT(*) as cantidad
FROM titles GROUP BY type
SELECT type, COUNT(*) as cantidad,
SUM(price) as precios FROM titles GROUP BY type
SELECT type, royalty, COUNT(*) as cantidad,
SUM(price) as precios FROM titles GROUP BY type, royalty ORDER BY type ASC, cantidad ASC
SELECT tits.type, tits.pub_id, SUM(tits.ytd_sales) as Ventas_año
FROM authors aut INNER JOIN titleauthor tit ON aut.au_id=tit.au_id INNER JOIN titles tits ON tits.title_id=tit.title_id WHERE aut.city='Oakland' GROUP BY tits.type, tits.ytd_sales, tits.pub_id ORDER BY tits.type, tits.pub_id
SELECT tits.type, tits.pub_id, SUM(tits.ytd_sales) as Ventas_año
FROM authors aut INNER JOIN titleauthor tit ON aut.au_id=tit.au_id INNER JOIN titles tits ON tits.title_id=tit.title_id WHERE aut.city='Oakland' GROUP BY tits.type, tits.pub_id ORDER BY tits.type, tits.pub_id