Jump to content

Count problem


inbowns

Recommended Posts

I have a database which I was successfully able to pull data from and utilize but now I have a problem. I need to get data from a column that I have Yes or No in and I'm not sure to go about retriving this data. I basically need to count all the data that is listed as Yes.

 

Any help is greatly appreciated.

Link to comment
Share on other sites

SELECT count(*) as yes_count FROM table_name WHERE column_yes_no = 'Yes'

 

Should do it.

 

Thank you for your reply I tired that and it works but I have other stuff that goes in the statement.Do you think you can help me clear that up also?

 

$sql ="SELECT effdate, carrier, COUNT(carrier), SUM(employees), COUNT(employees),COUNT(migrate) FROM info WHERE effdate BETWEEN '$date_search_1' AND '$date_search_1' GROUP BY carrier" AND migrate = 'Yes' ";

Link to comment
Share on other sites

Your syntax is invalid...

 

$sql ="SELECT effdate, carrier, COUNT(carrier), SUM(employees), COUNT(employees),COUNT(migrate) FROM info WHERE effdate BETWEEN '$date_search_1' AND '$date_search_1' AND migrate = 'Yes' GROUP BY carrier ";

Link to comment
Share on other sites

Your syntax is invalid...

 

$sql ="SELECT effdate, carrier, COUNT(carrier), SUM(employees), COUNT(employees),COUNT(migrate) FROM info WHERE effdate BETWEEN '$date_search_1' AND '$date_search_1' AND migrate = 'Yes' GROUP BY carrier ";

 

Yes I understand because it doesn't run am I using too many AND's

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.