Giter VIP home page Giter VIP logo

echo360-sql-assessment's Introduction

Echo360 SQL Assessment

SQL problems

Question 1

Given the following table:

track_media

auto_inc mediaid modified
1 x 2001-02-01
2 x 2001-01-31
3 y 2001-01-31
4 y 2001-02-01
5 y 2001-01-30
6 z 2001-01-26

Write a SQL query that yields the most recently modified auto_inc value for each mediaid.

SELECT auto_inc
FROM track_media t1
WHERE modified = (
	SELECT MAX(modified)
	FROM track_media t2
	WHERE t1.mediaid = t2.mediaid
);

Returns the below results:

auto_inc
1
4
6

Question 2

Given the tables:

user_sales

userid saleid
1 1
1 2
1 3
2 3
2 4
3 5
3 6
3 7
4 8

sale_amount

saleid amount
1 $4.00
2 $3.50
3 $2.00
4 $3.75
5 $5.25
6 $3.00

Write a SQL query that yields the userids that have total sale amounts greater than 4 dollars and less than 6 dollars.

SELECT userid FROM (
	SELECT u1.userid AS userid, SUM(s1.amount) AS total_amount
	FROM user_sales u1
	JOIN sale_amount s1
	ON u1.saleid = s1.saleid
	GROUP BY u1.userid
	HAVING total_amount > 4
	AND total_amount < 6
);

Returns the below results:

userid
2

echo360-sql-assessment's People

Contributors

alapp87 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.