简体   繁体   中英

SQL date comparison on sql

need help in getting this logic side by side. I am using 3 fields in a table.

Select Year, Date, Revenue from Sale

The result will be like this

Year   Date       Revenue
2014 01/02/2014    500
2013 01/02/2013    250
2014 02/02/2014   750
2013 02/02/2013   250

Here is what I need to display

2014   01/02/2014  500  2013 01/02/2013  250  
2013   02/02/2014  750  2013 02/02/2013  250   

The one we need to show should display in 4 columns. I tried some self join but it is cartesian product. Not sure it works. Please help me with this logic

It seem like Pivot table, and you can try to do like this example :

Pivot Table

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM