Question for SQL gurus: how can I select distinct and sort by number of duplicates?

Posted by admin on December 29th, 2009 and filed under select distinct | 4 Comments »

I have a table with 3 fields: zip, city, state. One row for every zip code in the US, it contains about 39,000 rows.

I want to search by city name alone. Some cities, such as "Rockford", will return many rows, in several different states.

If I do "SELECT * FROM ziplist WHERE city = ‘Rockford’", I might get:

zip – city – state
=================
00123 Rockford MI
00124 Rockford MI
00125 Rockford MI
60109 Rockford IL
60110 Rockford IL
60111 Rockford IL
60112 Rockford IL
91832 Rockford CA

3 Rockfords in MI, 4 Rockfords in IL, 1 Rockford in CA.
I need a query that will return a table that looks like this:

city – state
=================
Rockford IL
Rockford MI
Rockford CA

So that a user can choose which state he meant to search for, with the most probable result at the top. Very simple; distinct state, sorted by the number of times that state was repeated.

I’m using MySQL Server 4.1.13a.
gman: I think you meant "GROUP BY state",
otherwise it works great! Thanks!

I’m not sure I count as a SQL guru, but I have something you could try.

SELECT state, count(city) as cityCount
FROM ziplist
WHERE city=’Rockford’
GROUP BY state — Of course!
ORDER BY cityCount DESC

Good luck!

Where can I get sample follow-up letter for query letters sent to movie producers?

Posted by admin on December 29th, 2009 and filed under query | 2 Comments »

Say you sent a query letter to some movie producers and now you want to send a follow-up letter to see if they receive and if they take your movie. I need a follow-up letter sort of like that.

say —> dear sirs and madams:
i am writing in regards to a recent proposal letter which you received on or about________________2006. I am requesting your educated opinion with respect to the play/prose entitled _________________ a.s.a.p.
I will be in town for the next short while, and then will be away on business. However do send your correspondence to this address ____________________. I should be returning on or about ______________________ 2006 and will then administer to your correspondence.
thank you for the opportunity to do valuable business with you.
yours graciously, joe boxer.

How does a database work in a large retail store?

Posted by admin on December 27th, 2009 and filed under database | 2 Comments »

How does a database work in a large retail store, per store, such as Home Depot for example? For example is there a central database for a specific store that has all the products (just the products) that are currently availible on the shelf in the store? (Talking about specific stores, rather than an overall db for a whole franchise or region).

Retail companies use POS (Point of Sales systems) at each store location. These are the scanners that you see at check-out counters. When the item is scanned in, the database is updated. The data contained in this database is available for all stores. Using reporting, you can then get to store/region/item specific data.

For example, when Wal-Mart sells a Spiderman Backpack, item XYZ at its store #948 in California, the database will be updated. An analyst/buyer will then be able to send another backpack to that store, to fill back up (replenish) the one that was sold. A Buyer might be able to analyze the trend that California stores were doing really well with Spiderman Backpacks, etc.

Generally any retailer that has a centralized buying/ordering office (and all the big retailers do), has a centralized database.

Could I have tatoos and still be able to join the army (UK)?

Posted by admin on December 24th, 2009 and filed under inner join | 6 Comments »

I’ve heard from friends that they may not let me join because of them, and I want to have ravens done on my shoulders, or considering runes down my forearm (inner elbow to wrist)
would I be accepted if I have these done?

As said, as long as they are not offensive, racist, etc, etc, etc.

As for the one you plan to have from your "Elbow to your Wrist"…

…Ultimately err on the side of caution, and ensure the Tat finishes as high as possible (without ruining the original Tat) on your Fore-arms m8 :o )….

…No Tattoo may be visible below the Wrist line, so ensure when you have it done, it finishes a good couple of inches above your Scaphoid Bone, as a rough guide.

The regulations state that they must not be visible on the backs of, or any part of the hands and wrists whilst wearing a "Long Sleeved Shirt" in No.1 Dress Uniform. Furthermore, obviously non that are visible above the neckline of a "Collared Shirt". So no Tat’s on your Neck, Head or Face!!!

I have several, one on my right fore-arm, they were never a problem with ONE exception LOL…..

…You may find that if you have a new Tattoo completed whilst serving, the Dentists may insist on you having a blood test before they will treat you too.

I served in the R.A.F., and the Dentists questionnaire you complete prior to any treatment specifically asks if you have had any new Tattoo’s (hard to believe, BUT I s*** you not lol). Obviously the concern for them is the contraction of HIV, or Hepatitis, etc.

Good luck with your recruitment and if you make it, your career ;o)!

SQL help please. Thanks.?

Posted by admin on December 24th, 2009 and filed under select distinct | 1 Comment »

Hi, I have the query

select distinct programcode, dept from studentaffairsview where termcode = ‘200900′;

I want to only show results where the programcode appears more than once. Can this be done?
Thanks

This’ll do it.

Select Count(programcode) as Instances, programcode from studentaffairsview
Where termcode = ‘200900′
Group by programcode
Having Count(programcode) > 1

How to connect a textbox to a database in php using ms access?

Posted by admin on December 24th, 2009 and filed under database | 1 Comment »

I have an order form desined in php. To use it I need to connect it to a database. I use Yahoo hosting service. My website is www.ibexstudents.com. It has no support for asp but supports php, javascript and perl. Any other innovative approaches are welcomed.

Please give me the full procedure as I am not very good at programming. Thank you.

Assuming you have odbc driver , and dsn registered on your webserver, this is how you do it.
<?php
$db=’your databse name’;
$usrname=’username’;
$pwd=’your password’;
$conn = odbc_connect($db,$usrname,$pwd);
?>
Now let us assume you want to update your database with something that user inputs in your text box, lets say his Display name on your website, and password.
Lets assume textbox for name is txtname and for password (type="password" for asterics) is txtpass.
When user clicks on submit (name btnsubmit), lets say this info should be updated in a table called User in your database $db. Also assume form method is post and action is on same page (example newuser.php)
<?php
if(isset($_REQUEST['btnsumbit']))
{
$query="insert into table User values(’".$_REQUEST['txtname']."’,'".$_REQUEST['txtpass']."’)";
odbc_exec($conn,$query);
?>
}
Ofcourse this code dont handle any errors/exceptions and if u want to fetch data from database. u can use method
$recordset=odbc_exec($conn,$query);
odbc_fetch_row($recordset);
where query could be something like select * from User.
Good Luck!

Can i put a wood burning fireplace insert into my gas log fireplace?

Posted by admin on December 21st, 2009 and filed under insert into | 1 Comment »

I have an old coal fireplace that was converted into a gas log fireplace….I hate gas and i want to put a wood burning insert…is this possible? I figure i’d have to reinforce the chimney with something…but i don’t know what….any help would be nice.

Have your chimney professionally checked out. That may be the reason the previous owners stopped using the fireplace. If it is cracked, you can insert a flue just smaller than the chimney and attach it directly to the wood burner insert.

Make sure the gas lines are completely removed, again, use a professional.

I have a wood burner and love it, good change.

How much should I honestly be making at this job?

Posted by admin on December 21st, 2009 and filed under structured query language | 2 Comments »

I work as the only on staff IT worker in a business that holds about 15 employees. I consider myself a hybrid, in the sense that I fill both a Database Administrator and System Analyst position at once, but feel I am strongly underpaid. Since I’m the only one with technical knowledge in the business, there is no one knowledgeable enough to really evaluate what I do and how much I should really be getting paid. I plan to take these answers to my evaluation in a couple days to hopefully make some changes. Here is what I do (that I can think of off the top of my head):

Design and implement data structure for all applications and programs.
Create queries to retrieve data as needed.
Design and implement user interface.
Create system documentation.
Write stored procedures for SQL Server
Creates backup procedure and physically backs up necessary data.
Evaluates hardware/software needs for business, makes purchases, keeps inventory.
Fixes/manages printers/copiers, refills toner cartridges to save money.
Assists users in functionality.
Buys new computer systems based on needs of user and their position.
Manages wireless/land-line bills, manages changes of circumstances (i.e. someone leaving the country, etc.) Negotiates refunds on usage charges.

Languages I use: SQL, VB, C/C++, Java

Current Salary: $44,000 (No medical, dental, or vision coverage. No tuition reimbursement. 10 Vacation days/year starting after 1 year of working)

Is this fair? If not, what should I be making?

Thank you for your help.
Oh yes, it’s also a 7:00 a.m. – 5:00 p.m. job, Monday – Friday, no breaks, 30 minute lunch each day.

it kind of depends on where you live, and how long you’ve been working there/how much prior experience you have

it does sound maybe a little on the low side, but i’m sure there are people out there doing the same work for less money

What do I need to become a database programmer or a systems administrator?

Posted by admin on December 21st, 2009 and filed under database | 3 Comments »

What do I need to become a database programmer or a systems administrator? What programming languages do I need to know for these? Do i need a lot of math or a computer science degree for this?

I’d really like to have a job where i not only maintain a network but also one that I would be able to do programming in like with Java or C++.

Thanks!

If you posess a degree – or any other qualification – then you’ll already be in advace of of the masses when it comes to looking for vocations. My friend has a degree and he wasn’t sure what direction to go with it, but he uncovered some good tips on the website in the resource box below which aided him to decide that he wanted to be a lab assistant. There is plenty of guidance on the website regarding other vocations.

Why when I go into yahoo games it kicks me off when i select a game like pool. It totally exits out?

Posted by admin on December 19th, 2009 and filed under select into | 1 Comment »

When I go into yahoo games like pool and I select the game, it kicks me off and exits my browser. Please help

Yahoo has been having some problems with its yahoo games, but I just came from there and it appears to be fine now/