sql - Get a value based on another column's value -


it's pretty basic sql statement imagine, can't life of me figure out how do.

so have table have 3 columns : amount of car sold (aocs), day of week (dotw), previous day of week (pdotw).

i'd have amount of car sold previous day in fourth column. example, let's have sold 4 cars on monday, 5 cars on tuesday, 3 cars on wednesday.

on tuesday line, i'd have '4' written, amount of cars sold on monday.

i'm not sure if make sense, let me know. thank help!

you have join table on itself

select a.dotw, a.aocs, a.pdotw, b.aocs    my_table left join   my_table b  on   a.pdotw=b.dotw 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -