![]() |
|
|
#1 |
|
Junior Member
Join Date: Feb 2006
Posts: 3
|
Help Needed !!
Trying to run a report with following features:
-on same report line data from two records in the same table -table structure CUST YEAR MONTH SALES ... 1234 2006 01 1000 1234 2006 02 1200 ... ..... .... 1234 2005 01 800 1234 2005 02 600 ... ..... .... -report structure for the monh of 01: CUST YEAR MONTH SALES SALES2005 1234 2006 01 1000 800 .... I'm newbi and tried hard but without success so far... Help needed! konja |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Jul 2004
Posts: 167
|
Re: Help Needed !!
Can you explain your question better?
You probably can solve this with a self join.
__________________
** Most misspellings intentional to combat spaham filterz** |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Feb 2006
Posts: 3
|
mysql db table look much like this:
-only one table, only one "record" per CUST,YEAR,MONTH CUST YEAR MONTH SALES ... 1234 2006 01 1000 1234 2006 02 1100 1234 2006 03 1200 1234 2006 04 1100 1234 2006 05 1000 1234 2006 06 1400 ... ..... .... 1234 2005 01 800 1234 2005 02 600 1234 2005 03 1600 1234 2005 04 700 1234 2005 05 900 ... ..... .... 1244 2006 01 500 .... ...... ..... -report structure for the monh of 01: CUST YEAR MONTH SALES SALES2005 1234 2006 01 1000 800 .... The point is to get into the report: sales of the current period as well as sales of the period one year ago. I think this should be rather easy if one has experience which I don't yet have. Thank you very much for helping. konja ![]() |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Jul 2004
Posts: 167
|
Re: Help Needed !!
If you want to programmatically get the previous year into the report without sending a SELECT statement specifying the actual year/month, you probably want to look at the documentation about time and date handling. But you seem to be hardcoding dates into the data so maybe you can get away without it.
Let's start with a simple Select statement and maybe work from there. SELECT sales FROM mytablename WHERE CUST = '1234' AND MONTH='01' AND (YEAR='2006' OR YEAR='2005') ORDER BY year DESC I may have the syntax slightly off, and depending what programming language you are using, you may have different ways to access the current and previous year, whereas I hard coded it here as 2006 and 2005. Try that out and see if it works.
__________________
** Most misspellings intentional to combat spaham filterz** |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Feb 2006
Posts: 3
|
Re: Help Needed !!
Hi!
Thank you for your kind reply. One point I forgot to tell was that I want to have on the report on the same ROW both 2006 and 2005 numbers! However I found the solution myself after trying hard with "inner join". Nice having you guys helping, Looking forward later on coming back if some problem come ahead. konja / Finland ![]() |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help needed on setting up a database! | AKKI | Installation | 1 | 07-07-2005 03:53 PM |
| Recursive Help Needed 4.0.22 MySQL | Vmusic | SQL syntax | 3 | 12-16-2004 10:10 AM |
| Mysql with automatic import scheduling feature needed | lousueyesh | Utilities | 0 | 11-26-2004 02:07 PM |