?
Solved

perl code

Posted on 2004-11-03
7
Medium Priority
?
938 Views
Last Modified: 2012-08-13
#connect to the database
my $dbh = DBI->connect('dbi:mysql:rvsi','','', {RaiseError=>1, PrintError=>1});

# Extract the data from database
my $d = $dbh->selectall_arrayref("SELECT date, qin, qout,yield, reject, lot FROM yield WHERE date BETWEEN '$datef' AND '$datet'");
    print ("Daily Yield Report Summary for '$dev' between '$datef' to '$datet'\n\n");
    print ("Date\t\t", "Qin\t", "Qout\t", "Yield\t", "Reject\t", "Lot\n");

# Print out all the array catch  
foreach my $r(@$d) {
    print join("\t", @$r), $/;
}


hi..
the above perl code allows me to crunch data from the db according to the date given by the
user. jus wan to know can the data be crunch and display each individual day in a month?
eg day 1 all the way to day 30 or 31 another eg is
my $d = $dbh->selectall_arrayref("SELECT date_format(date, '%b'), sum(qin), sum(qout), ((sum(qout)/sum(qin))*100), sum(reject) FROM yieldall WHERE year(date) = '$year' AND job = '$dev' GROUP BY date_format(date, '%b') ORDER BY date")


if possible can anyone provide samples.

thank u.
0
Comment
Question by:TPoly
  • 3
5 Comments
 
LVL 15

Expert Comment

by:nicholassolutions
ID: 12566232
I'm not sure exactly what you want. Can you please give more concrete info about what you would like to do?

Thanks,
Matt
0
 
LVL 1

Expert Comment

by:tstoeckigt
ID: 12583689
That's probably no perl question but about sql. We have to know the used database to tell you the right sql-statement.

Ciao
Timo
0
 

Author Comment

by:TPoly
ID: 12679586
i'm using mysql as my db
0
 
LVL 15

Expert Comment

by:nicholassolutions
ID: 12697688
I'd love to help you out, but I still am unsure of what you want to do -- can you please be more specific about exactly what you are trying to achieve?
0
 
LVL 15

Accepted Solution

by:
nicholassolutions earned 500 total points
ID: 12697796
It also depends on what version of MySQL you are using (some of the very useful date functions have only recently become available), and how you have stored your date information...I would check out this page if I were you:

http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html

What you probably want is something like this:

SELECT * FROM table WHERE date1 <= date_column AND date2 >= date_column;

This should select all rows from your database where the date you have stored in date_column is between date1 and date2.

-Matt
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question