count

Sorting MYSQL Tag table

Hi there, just wondering if it is possible to get the top 10 COUNT results and ordering by COUNT and alphabetically? I have the following tables, tags ------- id | title . tagged ------ tag_id | post_id And the following SQL query SELECT tag.*, COUNT(td.tag_ID) AS tagcount FROM Tagged td LEFT JOIN Tags tag ON td.tag_ID = tag.tag...

Manually increment or decrement file reference counter (refcount) used by MSI installers?

My understanding is that MSI installers use a file reference count to keep track of how many 'installers' installed a shared file (say a dll). [HKEY_LOCAL_MACHINE]\SOFTWARE\Microsoft\Windows\Current Version\SharedDLLs This way, say 3 products all install the same DLL, the refcount is at 3. When you run the uninstaller for one of the pro...

Running Counter in SQL 2008

Hi all, I'm trying to establish a temp table for a running inventory demand report in SQL 2008. I can get the results that I am looking for until I hit an invoice with multiple lines. Here is the code so far: --Gather Current Order Data DECLARE @b TABLE ([Planned Shipment Date] DATE, [Order] VARCHAR(15), [Line Number] VARCHAR(15), [L...

I'm not getting the expected result from an SQL query.

I'm developing a search function for a website. I have a table called keywords with two fields id and keyword. I have two separate search queries for AND and OR. The problem is with the AND query. It is not returning the result that I expect. The printed SQL is : SELECT COUNT(DISTINCT tg_id) FROM tg_keywords WHERE tg_keyword='keywor...

COUNT and a sub COUNT in same query

Hi, I have 2 tables: members, orders. Members: MemberID, DateCreated Orders: OrderID, DateCreated, MemberID I want to find out the number of new members in a given month broken down into number of order groups, eg. 5+, 4, 3, 2, 1, 0 I've got the query to work out the number of orders for a member but how can I get these values in o...

Error when COUNT after MAX ?

Hi, I have a table Act in a medical database : IDAct Historic IDPatient 1 2001-01-01 1 1 2001-01-02 1 2 2001-01-01 2 3 2001-01-03 1 I would like to compute the column IDActPerPatient: IDAct Historic IDPatient IDActPerPatient 1 2001-01-02 1 1 2 2001-01-01 2 ...

jquery count li's in top level UL

Hi All, I need to count the amount of LI's in a top level UL. My top level menu has 6 items in it but this could dynamically change. I thought this could work but it is still counting the child li's too :( var numTopNavItems = 0; $("ul.rmHorizontal > li").each(function (i) { numTopNavItems += i; alert("numTopNavItems = " + n...

Using count() on a class that implements Iterator in PHP

Quick question really: I've seen in bits of code in the past where the code could call count() on a object that implements Iterator, for custom Iterator classes. I've written a class that implements Iterator and works fine in a foreach loop, but I was just wondering if there was an extra class I had to extend or function I had to imple...

MYSQL: How to find out the qty of unequipped items?

Here is my DB Structure: CREATE TABLE IF NOT EXISTS `UserItems` ( `id` bigint(20) unsigned NOT NULL auto_increment, `user_id` int(10) unsigned NOT NULL, `item_id` int(10) unsigned NOT NULL, `qty` int(11) NOT NULL default '0' ) ; CREATE TABLE IF NOT EXISTS `UserEquippedItems` ( `user_id` int(10) unsigned NOT NULL, `user_it...

column count based on a range

I have a student marks table with schema as given below: Student -------- SNO Marks I want to produce a result something as this: MarksRange Count ---------- ------ 0 10 10 2 20 43 : : 100 2 The above results shows that there are: 10 students who got a score zero, 2...

how to counting data from each column in MySQL?

i have some mysql script for pivot table and then counting some data inside that: SELECT A.Line, week1.1stweek, week2.2ndweek, IFNULL(week1.1stweek,0) + IFNULL(week2.2ndweek,0) AS TOTAL FROM inspection_report AS A LEFT JOIN( SELECT Line, (SUM(S) + SUM(A) + SUM(B)*0.4 + SUM(C)*0.1)/COUNT(Serial_number) AS 1stweek...

How to get COUNT from stored procedure return?

I have a stored procedure in SQL which I can't change. It needs few input parameters and returns a table with 100+ rows and several columns. exec dbo.Select_Data 0, 0, 18, 50 I need something to get count of returned rows: select count(*) from (exec dbo.Select_Data 0, 0, 18, 50) and a way to get values from e.g. Name column:...

making daily report with MySQL

i want to make some daily report which order by date. i want this data can increase every day. Date qty QP 2010-09-01 10 10 2010-09-02 3 13 (it means result QP from 2010-09-01 accumulate with 2010-09-02) 2010-09-03 8 21 this is the 1st code: SELECT Date, SUM(number) AS qty FROM...

counting rows before processing with a cursor tsql

hi there I have a SQL Server sp using a cursor thus: DECLARE TestCursor CURSOR FOR SELECT tblHSOutcomes.strOutcomeName, tblHSData.fkHSTest FROM tblHSData INNER JOIN tblHSOutcomes ON tblHSData.fkOutcome = tblHSOutcomes.uidOutcome INNER JOIN tblHSTests ON tblHSData.fkHSTest = tblHSTests....

Subsonic Count Distinct

enter code hereHow do I get the distinct count the ProdID column in this aggregate query? Dim query As SubSonic.SqlQuery = New SubSonic.Select(SubSonic.Aggregate.GroupBy(TOrders.DelivDateColumn, "DelivDate"),SubSonic.Aggregate.Count(TOrders.ProdIdColumn, "ProdId")).From(of TOrders) If I add Distinct() at the end, its working on the re...

count data in current month in MySQL

dear all. i have a lot of data in my database. after that i have some MySQL code for counting data. i want to make them can count monthly. how to make this code can count just in current month? its mean if now september, it was just counting on this month. and the data from the other month is ignored. whats MySQL code to make it so th...

Sql - struggling with count/having query based on several joins

Hi, I'm struggling to get my query working. Basically, what it should do is only return vacancies that haven't been filled. For example, a vacancy can have a pre-determined limit of 5. To fill this, it will need to have a mixture of 5 active or pending bookings or simply 5 active or 5 pending bookings. A pending booking is changed to a...

MySQL COUNT in two tables same time.

Hello! My question is not so hard, i just really can't find the answer anywhere. I've got 3 tables. webshops, webshop_category and webshop_item. My query is: SELECT webshops.id, webshops.name, webshops.tax, webshops.contact_name, webshops.contact_email, webshops.contact_phone, webshops.contact_address, COUNT(webshop_category.id), CO...

Counting characters in C

Hi all I'm trying to write a program that counts all the characters in a string. I originally had it, but then realized I can't count spaces. I can't see why this does not work. for(m=0; z[m] != 0; m++) { if(z[m] != ' ') { charcount ++; } } Any assistance appreciated. Edit* Does it make a difference if the input(str...

Getting this query to work?

Heya!, I have the below query: SELECT t1.pm_id FROM fb_user_pms AS t1, fb_user_pm_replies AS t2 WHERE (t1.pm_id = '{$pm_id}' AND t1.profile_author = '{$username}' OR t1.pm_author = '{$username}' AND t1.pm_id = t2.pm_id AND t2.pm_author = '{$username}' AND COUNT(t2.reply_id) > 0) AND t1.deleted = 0 ...