I have a Coupon model that has some fields to define if it is active, and a custom manager which returns only live coupons. Coupon has an FK to Item.
In a query on Item, I'm trying to annotate the number of active coupons available. However, the Count aggregate seems to be counting all coupons, not just the active ones.
# models.py
cla...
How can I use the function FIND to count the number of items of a given value instead of using a loop? For example, in the array item below there are 3 occurrences of the number 23, 2 occurrences of the number 22, and 2 occurrences of the number 20.
....
for i=2:n
if item(i-1)~=item(i)
nItem21(i)=1;
else
nItem21...
What is the optimal / acceptable column count when you are designing a table that serves as a datastore for huge forms to be filled?
...
I am trying to count the number of rows in a table that have an area, how can I achieve this, I currently have this query written,
SELECT DISTINCT area
FROM cv
WHERE status = 'SHOW'
AND is_complete = 'TRUE'
ORDER BY area ASC
This query currently returns,
area
------------------
West Yorkshire
Lanchashire
What I am w...
I am using the Projections.rowCount() function on Hibernate, but it will only return the counts greater than 0. I need to get the list with the 0 count too.
This is the function supposed to give me the count but it only returns counts greater than 1.
public List<Object[]> getCuentaPorEnlotar() {
DetachedCriteria criteria = casosEst...
I have to create a browse page like monter.com or dmoz directory. My problem is the counts for each category.
What's the best practive to do a similar thing?
I am using PHP/MySQL
Thx!
...
Hello all and thanks in advance
I have the tables accounts, votes and contests
A vote consists of an author ID, a winner ID, and a contest ID, so as to stop people voting twice
Id like to show for any given account, how many times theyve won a contest, how many times theyve come second and how many times theyve come third
Whats the faste...
It's a bit difficult getting my problem into a short form, so I apologise if the title doesn't make sense.
Anyway, here is the problem:
$query = '
SELECT issues.*, comments.author AS commentauthor, favorites.userid AS favorited FROM issues
LEFT JOIN comments ON comments.issue = issues.id AND comments.when_posted = issues.when_upda...
i've done this code to count the numbers of row in a db
int rows = 0;
if (sqlite3_open([[SqliteManager getDBPath] UTF8String], &database) == SQLITE_OK) {
const char *sql = "select count(*) from artheca";
sqlite3_stmt *countstmt;
if(sqlite3_prepare_v2(database, sql, -1, &countstmt, NULL) == SQLITE_OK) {
...
I have a table that looks like this:
episodes
------------------------------------------------------------
id (PK serial) | show_id (int4) | episode_number (int2[])
------------------------------------------------------------
1 | 1 | {1}
2 | 1 | {2}
...
How can I count how many fields there are in this row:
$row['number']
while ($row = mysql_fetch_array($result))
{
echo '
<td class="alt">'.$row['number'].'</td>
$number = $row['number']
}
...
I'm trying to find a SQL query that will count the number of distinct start times that are at least 30 minutes different.
I have a number of employees that are paid a credit when they start work on at least three distinct times in a week, where the start time is at least 30 minutes different from the other start times.
For example:
se...
Hello, I'm trying to count the execution time of part of my application, but since I need to get milliseconds, and I need to get long execution times too. I'm currently using clock_t = clock() from ctime, but it has a range of only 72 minutes I think, which is not suitable for my needs. Is there any other portable way to count large exec...
I have run into the following situation several times, and was wondering what best practices say about this situation:
Rows are inserted into a table as users complete some action. For example, every time a user visits a specific portion of a website, a row is inserted indicating their IP address, username, and referring URL. Elsewhere,...
I am trying to count a substring, while matching different values from another column. The following statement gives me a syntax error on the where clause.
Is the following even possible, and what is the correct syntax?
select address,
datacenter,
ifdesc,
count(substring(ifdesc, 'Ethernet0/*') where ifadminstatus ...
I have two Postgres databases. In one I have two tables, each with about 8,000,000 rows, and a count on either of them takes about a second. In another database, also Postgres, there are tables that are 1,000,000 rows, and a count takes 10s, and one table thats about 6,000,000 rows, and count takes 3min to run. What factors determine ...
I have a list of users that only administrators can see (= few reads). This list also displays a count of the number of users in the datastore. Because the list could grow larger than 1000 my first thought was to avoid a normal count() and instead use a sharded counter.
However, the problem is that the admins also have access to various...
I have a table with a text column that contains various bits of data.
For example
Hello world
This is a piece of text
Q1 3
New text
Q2 2
Q1 2
Q1 3
More text
The bits of text trhat have Q1 at the start are pieces of voting data and are the bits I am interested in.
How can I write a query that gets counts of voting data ...
Simple and fast question, i have those tables:
//table people
| pe_id | pe_name |
| 1 | Foo |
| 2 | Bar |
//orders table
| ord_id | pe_id | ord_title |
| 1 | 1 | First order |
| 2 | 2 | Order two |
| 3 | 2 | Third order |
//items table
| item_id | ord_id | pe_id | title |
| 1 | 1 | 1 | ...
I am storing animation key frames from Cinema4D(using the awesome py4D) into a lists of lists:
props = [lx,ly,lz,sx,sy,sz,rx,ry,rz]
I printed out the keyframes for each property/track in an arbitrary animation and they are of different lengths:
track Position . X has 24 keys
track Position . Y has 24 keys
track Position . Z has 24 ke...