Hi,
I have a table USERS with the following fields
date(datetime)
email(varchar)
provider(int)
event(int)
I am looking for how many records there are with the same email, which occur in a specific month with a specific provider.
like for provider= x and month = y i want
email occurs
[email protected] 5
[email protected]...
Hi,
I searched for this on the site already but couldn't locate anything that answered my question. Which brings me to the details:
I am querying database using a simple select query, realistically (given the scenario) it should never return more than about 5 to 6 records. I just want to check if more than one has been returned. And if...
I am searching for records in a table as follows:
SELECT Id, Name FROM my_table WHERE Name LIKE '%prashant%' LIMIT 0, 10;
Now, I am adding LIMIT to maintain my paging. But when user searches for word 'prashant' then total records I have is 124 for 'prashant'. But as the limit applied to the query so it only fetches 10 records in my PH...
I have a table of housing listings. I would like to keep a maximum of 10 listings per city.
(Most cities have less than 10 listings).
When I do this query:
select city, count(city) as cityCount from tREaltyTrac group by city
SQL returns:
Acampo 1
Acton 1
Adelanto 20
Agua Dulce 1
Aguanga 1
Akron 19
Albany 12
Albion 3
Al...
Here is my query:
select word_id, count(sentence_id)
from sentence_word
group by word_id
having count(sentence_id) > 100;
The table sentenceword contains 3 fields, wordid, sentenceid and a primary key id.
It has 350k+ rows.
This query takes a whopping 85 seconds and I'm wondering (hoping, praying?) there is a faster way to find all...
I have two tables: Toys and Games.
+--------------------+------------------+
| Field | Type |
+--------------------+------------------+
| toy_id | int(10) unsigned |
| little_kid_id | int(10) unsigned |
+--------------------+------------------+
+--------------------+------------------+
| Field ...
Is there a built-in function in PHP or MySQL that will provide the total number of MySQL queries used on a page? I've seen on a lot of sites (mainly forums) they have a message at the bottom saying something like "Page generated in 0.6 seconds with 20 queries".
If there's nothing built in then I'll add something to my database class to ...
I have two tables: "user" -> "order"
TABLE: user
user_id
-----------
u1
u2
TABLE: order
order_id | user_id | flag
-------------------------
o1 | u1 | fA
o2 | u2 | fB
Y need obtain all users counting how many times have orders with flag 'fA'
RESULTS WHAT I NEED:
user_id | orders
----------------
...
I find it cumbersome to create a trigger just to get the current total rows of the table without doing COUNT(*) FROM table. I'm thinking if their planned index-organized tables for Postgres 8.5 could make it possible?
...
What is a good approach to keeping accurate counts of how many times a page has been viewed
I'm using Django. Specifically, I don't want refreshing the page to up the count.
...
I am working on a database that contains 3 tables:
A list of companies
A table of the products they sell
A table of prices they offered on each date
I'm doing a query like this in my php to generate a list of the companies offering the lowest prices on a certain product type on a certain date.
SELECT
a.name AS company,
c.id,
M...
I have the following two tables (simplified for this question):
CREATE TABLE team (
teamID CHAR(6) NOT NULL PRIMARY KEY);
CREATE TABLE member (
memberID CHAR(7) NOT NULL PRIMARY KEY,
teamID CHAR(6) NOT NULL REFERENCES team(teamID) );
I also have the following query, which is to list the number of members in each team:
SELECT tea...
I need to get the total items in array, NOT the last id, none of both ways I found to do this works:
my @a;
# Add some elements (no consecutive ids)
$a[0]= '1';
$a[5]= '2';
$a[23]= '3';
print $#a, "\n"; # prints 23
print scalar(@a), "\n"; # prints 24
I expected to get 3..
Thank you in advance.
...
I want a certain action to happen when a user has visited X pages of a site
Do I have to store the counter externally (in a txt file or db)?
I can't think of a way to set the counter to 0, then increment it each page load. The counter would always get reset to 0, or am I missing something obvious?
...
Every visit to my website updates a user's individual hit counter and updates a column for time() based on their ip address and id stored in a cookie. So when coming to output the data, what's a more efficient way of my following code with less database calls, as it's essentially a copy of itself:
<?
$last1Min = time()-60;
$last5Mins = ...
Hi, I'm a python newbie, so maybe my question is very noob.
Assume I have a list of words, and I want to find the number of times each word appears in that list.
Obvious way to do this is:
words = "apple banana apple strawberry banana lemon"
uniques = set(words.split())
freqs = [(item, words.split.count(item)) for item in uniques]
print...
I have a query where I want to get distinct dates, the phone numbers associated with those dates, and a count of the phone numbers per date.
For example, I have a database with dates and phone numbers and I want the result to be
9/2005 5554446666 3
9/2005 4445556666 1
10/2005 1112223333 1
11/2005 2223334444 ...
This can be in any high-level language that is likely to be available on a typical unix-like system (Python, Perl, awk, standard unix utils {sort, uniq}, etc). Hopefully it's fast enough to report the total number of unique terms for a 2MB text file.
I only need this for quick sanity-checking, so it doesn't need to be well-engineered.
...
In sql i have a column called answer and it can either be 1 or 2, i need to generate an SQL query which counts the amount of one and twos for each month, i have the following query but it does not work:
SELECT MONTH(`date`), YEAR(`date`),COUNT(`answer`=1) as yes,
COUNT(`answer`=2) as nope,` COUNT(*) as total
FROM results
GROUP BY YEAR...
I cannot figure out how to write the following query using the DbFinderPlugin 1.2.2 with Symfony and Propel:
SELECT species, COUNT(*) FROM Bird GROUP BY species;
Here is the DbFinderPlugin page
I am rather new to the plugin, and I do love it so far, but this query has so far stumped me.
...