Shantanu's Blog

Database Consultant

November 20, 2005

 

Counting Coloured Cells

Counting coloured cells, either cell colour or font colour, is easily achieved with the function presented here. One of the major benefits of this routine is that it can utilise standard worksheet functions for summing the colours, without the need for a 'helper' column.

The function has been specifically designed to return an array of colorindex values that can be used in standard worksheet functions, such as SUM. In reality, it is best served by the SUMPRODUCT function to count the instances of a particular colour, using the following technique(s).

=SUMPRODUCT(--(ColorIndex(A1:A100)=3))
counts all red cells (background color) within the range A1:A100

or
=SUMPRODUCT(--(ColorIndex(A1:A100,TRUE)=3))
counts all cells with red text within the range A1:A100

To get the colorindex of a specific cell, simply use
=ColorIndex(A1)

As well as counting all cells with a particular colorindex value, it is possible to use the colour of a cell as the comparison, like this
=SUMPRODUCT(--(ColorIndex(A1:A100)=ColorIndex(A1)))

http://www.xldynamic.com/source/xld.ColourCounter.html#counting

November 19, 2005

 

Double Column charts




1) Select the data in B2:F3 and make a column chart. The chart will be blank!
2) Select B6:F22 and click the Copy tool. Select the chart and click the Paste tool.
3) Right click the North data series in the chart, open the Format Data Series dialog. On the Axis tab click on the Secondary Axis box to put a check mark in it.
4) Right click within the Chart Area and open the Chart Option dialog. In the Secondary Axis area, put a check mark in the Category (X) Axis box and remove the check mark from the Value (Y) Axis box.
5) In turn, format the other three data series to use the secondary axis. After this, when you click on a data series in the chart, the coloured range finder lines will enclose the data in B6:B22 and the y-values.
6) Right click any data series in the chart, open the Chart Type dialog and set the chart to stacked columns. If you do this without selecting a data series the x-axis labels will be totally unacceptable.
7) Right click on any data series in the chart, open the Format Data Series dialog, and on the Options tab set the Gap width to 0.
8) We need to hide the secondary x-axis. Do not merely clear or delete it. Right click on the secondary x-axis (top one) and open the Format Axis dialog. Set the Major and Minor tick marks to none. Set the Tick marks labels to none.
9) Click on the legend box and then click to select the Series 1 text. Press the Delete key.
10) Note, you may change the order in which the data is displayed. Open any Format Data Series dialog, open the Series Order tab and use the Move buttons to reorder the series to your requirements.
11) Remember there is a hidden secondary x-axis. This may interfere with the chart title if the two overlap. You may wish to use the secondary x-axis title as the chart title to avoid this problem.

 

Google SMS

Google SMS (Short Message Service) enables you to send queries as text messages over your mobile phone or device and easily get precise answers to your questions. No links. No web pages. Just text and the information you're looking for. You can use Google SMS to find definitions for a word or phrase on the Web. Enter 'define' followed by the word or phrase (or use the shortcut 'D' before the search terms) and send the message to the US shortcode 46645 (GOOGL on most phones).

Google SMS works on all major mobile providers in the US, including Alltel, Cincinnati Bell, Cingular, Nextel, Sprint PCS, T-Mobile, and Verizon.

http://www.google.com/sms/

November 05, 2005

 

TurboDbAdmin, presented by TurboAjax Group

TurboDbAdmin, presented by TurboAjax Group: A single-page solution for exploring and editing databases from a browser. Edit data just like you would in a desktop application, without submit buttons or page refreshes.
awesome and unbelievable!

http://www.turboajax.com/turbodbadmin.html

November 04, 2005

 

Talk to me!

Hi, What's up?
Answer: A new command called "dbsearch" is ready! You type it here...
http://saraswaticlasses.com

What does it do?
Ans: Search the MySQL data if phpMyAdmin is installed.

What is the syntax?
dbsearch -path http://saraswaticlasses.com/phpMyadmin/ -db contacts -search citibank

Can the parameters made shorter and easy to remember?
Ans: Yes! you can create a shortcut using the shortcut command like...
shortcut myadmin http://saraswaticlasses.com/phpMyAdmin/

So that the new command will be
dbsearch -path myadmin -db contacts -search citibank

Is the source code free, open, yummy, gikky and chikky?
Ans: Yes. The PHP source code of adminsearch.php is here...
http://www.bigbold.com/snippets/posts/show/855

Where can I say that this whole thing is crap and utterly useless?
Ans: At google groups discussion board.
http://tinyurl.com/bsvx3

November 03, 2005

 

MySQL Case Study - 88

Help with if/else query
I'm trying to consolodate the following 2 queries into 1. Right now, I'm using PHP to filter the condition. Is it possible using a mysql case condition?

PHP Code:

$contact_id = array(10,12,44,54,55,67);

for ($i = 0; $i < count($contact_id); $i++) {
//For each contact id, see if I have a cooresponding entry first.
$sql = "SELECT *
FROM my_contacts
WHERE contact_id = '$contact_id[$i]' && owner = '$my_user_id'";
$result = mysql_query($sql);

//If there is no entry under my id, just get the first row that cooresponds to this contact id
if (mysql_num_rows($result) == 0) {
$sql = "SELECT *
FROM my_contacts
WHERE contact_id = '$contact_id[$i]'
LIMIT 1";
$result = mysql_query($sql);
}

while ($row = mysql_fetch_array($result)) {
//Get the rows data here and store it in a php array...
}
}


The contact id array has already been created so we know these entries exist in the db. What we don't know is whether or not an entry exists under my user_id. If it doesn't just grab the next row corresponding to that contact id.

http://forums.devshed.com/t300140/s.html

 

MySQL Case Study - 87

Exclude NULL from Group By

Assume i have a simple table like this:

----------------------
| id | x | kind |
----------------------
| 1 | 7 | FISH |
----------------------
| 2 | 9 | BIRD |
----------------------
| 3 | 5 | NULL |
----------------------
| 4 | 3 | NULL |
----------------------
| 5 | 2 | FISH |
----------------------
| 6 | 1 | FISH |
----------------------

I would like to group results by KIND. However, i also want to return every row that doesn't have a KIND assigned, that is where the value is NULL. A normal GROUP BY clause:

SELECT max(x), kind FROM table WHERE x GROUP BY kind;

would simply group all NULL entries into one group and return:

2 - BIRD
6 - FISH
4 - NULL

But instead i would like to get only the "kind" column values grouped that exist and every row with where "kind" is NULL returned individually. The desired result would look like this:

2- BIRD
6 - FISH
3 - NULL
4 - NULL

I tried this with the iSNULL function, but this doesnt seem work on the GROUP BY clause. Can this be achieved in one query?

btw, it might seem silly to do this with the example given, but i just had to grossly simplify it. Thanks for your help.

http://forums.devshed.com/t301976/s.html

 

MySQL Case Study - 86

I have a table with 5 fields each one may have a value or NULL.
I need to add a 6th field with a numeric value based on each other field with the following condition:
If field is empty the value is 0
If field has value the value is 1
I need to concat all these value in the order of the fields so I have

field
A value
B value
C empty
D value
E empty

new field F=11010
I need something simple, quick which uses few ressources (like always ...)

http://forums.mysql.com/read.php?10,51150,51150#msg-51150

November 01, 2005

 

MySQL Case Study - 85

Using a variable with LIMIT in SELECT statement

Is it possible, either directly or with a decent workaround to perform a LIMIT on a SELECT statement using a variable?
For example, I want the top N results, where N might be passed in to a stored procedure, or even issued from the command line...

CREATE PROCEDURE `xx`(IN N INT)
SELECT * FROM `Candidate` LIMIT N;

This fails at 'LIMIT N' because, apparently, LIMIT has to be followed by a literal constant.
Is there a way to do this, or do I need to construct the SQL in my client and give up on using a stored procedure whenever I need a variable number of results?

http://forums.mysql.com/read.php?10,48728,48728#msg-48728

 

Open Source Strategies: Freeware vs Shareware vs Open Source

Open Source Strategies: Freeware vs Shareware vs Open Source: What are the differences between three models of "free" software, and why does it matter? With all the excitement, many people are actually confusing open source software with two other models of "free" software--with potentially serious consequences. Here, someone will try to clear it up.
http://opensourcestrategies.blogspot.com/2005/09/freeware-vs-shareware-vs-open-source.html


Archives

June 2001   July 2001   January 2003   May 2003   September 2003   October 2003   December 2003   January 2004   February 2004   March 2004   April 2004   May 2004   June 2004   July 2004   August 2004   September 2004   October 2004   November 2004   December 2004   January 2005   February 2005   March 2005   April 2005   May 2005   June 2005   July 2005   August 2005   September 2005   October 2005   November 2005   December 2005   January 2006   February 2006   March 2006   April 2006   May 2006   June 2006   July 2006   August 2006   September 2006   October 2006   November 2006   December 2006   January 2007   February 2007   March 2007   April 2007   June 2007   July 2007   August 2007   September 2007   October 2007   November 2007   December 2007   January 2008   February 2008   March 2008   April 2008   July 2008   August 2008   September 2008   October 2008   November 2008   December 2008   January 2009   February 2009   March 2009   April 2009   May 2009   June 2009   July 2009   August 2009   September 2009   October 2009   November 2009   December 2009   January 2010   February 2010   March 2010   April 2010   May 2010   June 2010   July 2010   August 2010   September 2010   October 2010   November 2010   December 2010   January 2011   February 2011   March 2011   April 2011   May 2011   June 2011   July 2011   August 2011   September 2011   October 2011   November 2011   December 2011   January 2012   February 2012   March 2012   April 2012   May 2012   June 2012   July 2012   August 2012   October 2012   November 2012   December 2012   January 2013   February 2013   March 2013   April 2013   May 2013   June 2013   July 2013   September 2013   October 2013   January 2014   March 2014   April 2014   May 2014   July 2014   August 2014   September 2014   October 2014   November 2014   December 2014   January 2015   February 2015   March 2015   April 2015   May 2015   June 2015   July 2015   August 2015   September 2015   January 2016   February 2016   March 2016   April 2016   May 2016   June 2016   July 2016   August 2016   September 2016   October 2016   November 2016   December 2016   January 2017   February 2017   April 2017   May 2017   June 2017   July 2017   August 2017   September 2017   October 2017   November 2017   December 2017   February 2018   March 2018   April 2018   May 2018   June 2018   July 2018   August 2018   September 2018   October 2018   November 2018   December 2018   January 2019   February 2019   March 2019   April 2019   May 2019   July 2019   August 2019   September 2019   October 2019   November 2019   December 2019   January 2020   February 2020   March 2020   April 2020   May 2020   July 2020   August 2020   September 2020   October 2020   December 2020   January 2021   April 2021   May 2021   July 2021   September 2021   March 2022   October 2022   November 2022   March 2023   April 2023   July 2023   September 2023   October 2023   November 2023   April 2024   May 2024   June 2024   August 2024   September 2024   October 2024   November 2024   December 2024  

This page is powered by Blogger. Isn't yours?