Query involving count and cross-referencing tables
Hi I have the 3 tables listed below, i need to total the days worked per job for every staff member for a certain month then list them in ascending order, any help would be appreciated!
staff - first, last, IDnum
jobs - ticketnum, date_closed
assignment - ticketnum, IDnum, date_assigned, status
notes - only if status is 'closed' should i calculate the days worked on the job
i know the nested queries are a bit nasty, but ive been at this for hours and cant seem to figure out calculating total days worked from the dates and totaling them
deleted
Similar Messages
-
How to query the count of the temporary table from user_objects
e.g. select count(*) from user_objects where object_type='TABLE'
According to the SQL,I can query the all table including the temporary table,Can I how to query the count of the temporary table from user_objects excluding the permanent table?
thanks a lot!select count(*) from user_objects where object_type='TABLE' and temporary = 'Y'
-
Query on Creating and Populating I$ table on different condition
Hi,
I have a query on creating and populating I$ table on different condition.In which condition the I$ table is created??And These condition are mentioned below:
1)*source and staging area* are on same server(i.e target is on another server)
2)*staging area and Target* are on same server(i.e source is on another server)
3)*source,staging area and Target* are on *3 different* server
4)source,staging area and Target are on same server
ThanksI am not very much clear about your question. Still trying my best to clear it out.
In your all above requirement I$ table will be created.
If staging same as target ( One database,one user) then all temp tables will be created under this user
If staging is different than target ( One database,two user (A,B)) then all temp tables will be created under this user A (lets consider) and data will be inserted to the target table that is present in user B
If staging is different than target ( Two database,two user (A1,A2), not recommended architecture) then all temp tables will be created under this user A1 (database A1) and data will be inserted to the target table that is present in user A2 (database A2)
If source,staging,target will under one database then No LKM is required,IKM is sufficient to load the data into target. Specifically for this you can see one example given by Craig.
http://s3.amazonaws.com/Ora/ODI-Simple_SELECT_and_INSERT-interface.swf
Thanks. -
Writing a query to count entries for all tables
I'd like to write a query to count the number of rows in every table for a given database. For example, if I have two tables in a database called TEST1 and TEST2 with 20 and 30 rows respectively, I'd like the output of the query to be
TABLE_NAME ROW_COUNT
TEST1 20
TEST2 30
Any ideas?or justin,
How about this
SQL> ed
Wrote file afiedt.buf
1 declare
2 t_count number;
3 begin
4 dbms_output.put_line('table_name Num_rows ');
5 dbms_output.put_line('---------- ---------- ');
6 for i in (select table_name from user_tables) loop
7 execute immediate 'select count(*) from '||i.table_name into t_count;
8 dbms_output.put_line(i.table_name||' '||t_count);
9 end loop;
10* end;
SQL> /
table_name Num_rows
EMP_TEST 0
BOOK 2
MONTH 36
BOOK_SALES 65
CURRENCY 2
EMP 18
BONUS 0
DEPT 5
SALGRADE 0
PLAN_TABLE 0
PL/SQL procedure successfully completed. -
Query output help: Display self-referencing table
Hello,
I'm trying to display in a cfoutput a self-referencing table.
I'll start by showing some of the data in the table.
There are only 3 columns, pl_id (auto increment id pri-key),
pl_name and pl_parent_id (it's 0 if it's a parent, otherwise it's
the pl_id value for the parent).
pl_id pl_name pl_parent_id
1 Country 0
2 Food 0
3 US 1
4 Japan 1
5 Hamburger 2
6 Idaho 3
7 Florida 3
8 Cheese 2
What I'm trying to output is something like this:
Country - US - Idaho (3 levels here) or
Country - US - Florida (or if there are only 2 levels like
the next line)
Food - Cheese
I've tried using a cfoutput with a cfloop as well as grouping
but not having any luck. Could someone clear my clouded head on
this one?
thanks much,
Joe
ps. Adobe should really use a fixed width font for these
forums, it's impossible to line up table info!JoeNH2k wrote:
> It would be nice if it were that easy, I (of course)
tried that. The sort order
> of the query doesn't matter. The data is not sorted once
the function runs. The
> sort has to come after the select box is populated by
the function. I need to
> get the data at this point and sort it, probably somehow
creating a structure
> or array from this data and sorting that(?).
>
<cfset myArr = ArrayNew(1)>
<cfloop query="qryGetAll">
<cfset temp = ArrayAppend(myArr,
"#getNameWithParent(pl_id)#")>
</cfloop>
<cfset ArraySort(myArr, "textnocase", "asc")>
<cfset myList = ArrayToList(myArr, ",")>
then loop through myList to populate your <select>...
how about that?
Azadi Saryev
Sabai-dee.com
Vientiane, Laos
http://www.sabai-dee.com -
How to write sql query for counting pairs from below table??
Below is my SQL table structure.
user_id | Name | join_side | left_leg | right_leg | Parent_id
100001 Tinku Left 100002 100003 0
100002 Harish Left 100004 100005 100001
100003 Gorav Right 100006 100007 100001
100004 Prince Left 100008 NULL 100002
100005 Ajay Right NULL NULL 100002
100006 Simran Left NULL NULL 100003
100007 Raman Right NULL NULL 100003
100008 Vijay Left NULL NULL 100004
It is a binary table structure.. Every user has to add two per id under him, one is left_leg and second is right_leg... Parent_id is under which user current user is added.. Hope you will be understand..
I have to write sql query for counting pairs under id "100001". i know there will be important role of parent_id for counting pairs. * what is pair( suppose if any user contains both left_leg and right_leg id, then it is called pair.)
I know there are three pairs under id "100001" :-
1. 100002 and 100003
2. 100004 and 100005
3. 100006 and 100007
100008 will not be counted as pair because it does not have right leg..
But i dont know how to write sql query for this... Any help will be appreciated... This is my college project... And tommorow is the last date of submission.... Hope anyone will help me...
Suppose i have to count pair for id '100002'. Then there is only one pair under id '100002'. i.e 100004 and 100005Sounds like this to me
DECLARE @ID int
SET @ID = 100001--your passed value
SELECT left_leg,right_leg
FROM table
WHERE (user_id = @ID
OR parent_id = @ID)
AND left_leg IS NOT NULL
AND right_leg IS NOT NULL
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
JTree, BC4J and self referenced table
Hello.
table OBJECTS which has a primary key ID and a parent ref PARENTID.
This is to have a tree structure of objects.
I want that viewed in a JTree structure (using jclient and bc4j's)
How do i do that? if i do the obvious and use the object view with itself as accessor,
The tree is fine except ALL objects are stored on the rootlevel (of course).
Is there a way to make a polymorphic restriction only on root level, or do I use two viewobjects to represent the data? (and how would i do that the right way?)
Or is there another way?
Thanks.Is there a way to make a polymorphic restriction only on root level, or do I use two viewobjects to represent the data? (and how would i do that the right way?)No you should not have to use Two different VOs. See a discussion on OTN thread:
Re: LDAP Authentication and DB user -
Error occurred when executing query involving cross join or outer join
Hi,
I tried to execute the following query:
select count(*)
from
po,
invoice,
table(xmlsequence(extract(invoice.content, '/CommercialInvoice/Body/LineItemDetails/LineItem'))) invoice_line_item
where
extractValue(po.content, '/PurchaseOrder/Header/DocumentID/RID') =
extractValue(value(invoice_line_item), '/LineItem/Product/PurchaseOrderIdentifier/documentCreatorIdentifier')(+)
It produced the following error:
Error: ORA-00936: missing expression
Then I change the query to:
select count(*)
from
po left outer join
invoice cross join
table(xmlsequence(extract(invoice.content, '/CommercialInvoice/Body/LineItemDetails/LineItem'))) invoice_line_item
on
extractValue(po.content, '/PurchaseOrder/Header/DocumentID/RID')
= extractValue(value(invoice_line_item), '/LineItem/Product/PurchaseOrderIdentifier/documentCreatorIdentifier')
It produced the following error:
Error: ORA-00904: "INVOICE"."SYS_NC0012900130$": invalid identifier
If I simply the query to:
select 1
from
invoice cross join
table(xmlsequence(extract(invoice.content, '/CommercialInvoice/Body/LineItemDetails/LineItem'))) invoice_line_item
It also produced the following error:
Error: ORA-00904: "INVOICE"."SYS_NC0012900130$": invalid identifier
What is the cause of the problem? How to resolve it?
The version I am using is 10.1.0.2.0 on Windows. Any help would be much appreciated.Hi,
Recently we went for BW upgradatiaon (BI7.0) , the error you are facing could be due to the following issue,
If infoobjects are used in infoset as infoprovider ( in BW3.5) after upgrade this infoobjects will not be selected automatically as infoproviders. So it will not be available for Infoset.
Please check whether any infoobjects are used as infoprovider, if so manually change them as infoprovider ( In BI7) and activate.
Since, few reports are working on the infoset , this could be those reports are not using the fields from the infoobjects. so it is working it seems.
Please check and let me know.
Thanks,
V.Senthil -
CRM tables for iBASE, Counter and pricing details.
Hi Everybody,
Can anybody help me with the name of the tables and the joining condition for iBASE, Counter and pricing agreement tables.
Say, I have only service contract number and GUID, to start with.
I'm looking for counter id and the reading, from iBASE. Then, using the pricing agreement, I want to convert the volume to an amount.
Regards,
Sanj.Hello,
Could you find a way out for creating counters in an IBASE component programatically?
Rgds
Priyanka -
Spatial Query across schemas. one version enabled table another not -Hanged
Hi,
I am executing a PL/sql procedure where a Spatial query run across two schemas. One table(in x schema) is version enabled and second table(in y schema) is Unversioned. Add to that complexity I am running the procedure from third user logon. I think I have enough previleges, as I won't get any error message.
But, Procedure worked fine when there is no table is version enabled. It started giving problem when one table got version enabled.
I have tried by setting " DBMS_WM.Gotoworkspace('LIVE');" before running spatial query. But still no luck, process just hangs on the spatial query.
I tried by using physical name of the Table (table1_LT) which is making it to work. But, as per Workspace manager guide, applications, programs should NOT use, this physical tables(because it is not the correct way on versioned table).
1. How can I hint to my query, to use a table from only live version?
2. Why Query is hanging forever (even tried by leaving it over night....)
Normally it used to take one or two minutes(before versioning..)
I have posted it Workspace manager forum, But No Luck (people seems to be shy away after seeing "Spatial query" )
Any help is highly appriciatedHi,
I will need to know more details about the specific query you are performing. So, please do the following:
1. list the actual query that you are using
2. generate an explain plan of the query both before and after the table was version enabled. use @?/rdbms/admin/utlxpls or anything that generates the predicate information.
3. also, give any pertinent details about the table(size of the table, number of rows expected to be returned, column types in the table, etc).
Based on that, I will see if I can suggest a possible hint that may be able to improve the performance of your query.
Regards,
Ben -
Self referencing table and SQL statement
In my database, I have a self-referencing table, the table itself is for projects, and it allows users to get a hierarchical view of the company.
Here is the SQL (modifier is the term we use for project code, BBCI is the top project)
SELECT
modifier, modifierDescription, level
FROM
modifier
WHERE
level <= 2
CONNECT BY PRIOR
modifier = parentModifier
START WITH modifier = 'BBCI'
ORDER BY level
That perticular query gets the first two levels in the structure. I use this information to produce a tree structure in a web app.
But users have requested it would be good if in the tree structure is showed an + or - depending on whether there were anymore children under each parent, or better still the number of children under it, for example
BBCI
+ BBCI_CHILD
+ BBCI_CHILD2
- BBCI_CHILD3
or
BBCI
+ BBCI_CHILD (3 projects underneath)
+ BBCI_CHILD2 (2 projects underneath)
- BBCI_CHILD3 (0 projects underneath)
I am really stumped on this issue, and I am sure there is a way to do this in the web app, so for example do a query for each child node to see how many child nodes are underneath, but I figure it would be a lot tidier and faster if I could do it from a single SQL statement. Unfortunately I have tried to do this and am very much stuck.
If you need more information please let me know
Thanks!
JonYou may be able to do this using analytical functions but it depends on the Oracle version you are using. It can also be done with standard SQL - you just need to count the number of child rows for each modifier/project first and supply that list as an in-line view:
SELECT decode(modifier,'X',null,decode(child_rows,null,'-','+')),
m.modifier,
decode(modifier,'X',null,'('||nvl(cq.child_rows,0)||' projects underneath)')
FROM modifier m,
(select parentModifier,
count(parentModifier) child_rows
from modifier
where parentModifier is not null
group by parentModifier) cq
WHERE m.modifier=cq.parentModifier(+)
AND level <= 2
CONNECT BY PRIOR
m.modifier = m.parentModifier
START WITH modifier = 'X'
ORDER BY level, modifier;
which gives you something like...
D MODIFIER DECODE(MODIFIER,'X',NULL
X
- Y1 (0 projects underneath)
+ Y2 (2 projects underneath)
+ Y3 (3 projects underneath)
The decode stuff is just to show you the result, you can format the output in your calling code. Just extend the columns to include everything you want, modifierDescription etc..
Hope this helps. -
Hi I am using oracle 10g. Trying to aggregate duplicate count records. I have so far:
SELECT 'ST' LEDGER,
CASE
WHEN c.Category = 'E' THEN 'Headcount Exempt'
ELSE 'Headcount Non-Exempt'
END
ACCOUNTS,
CASE WHEN a.COMPANY = 'ZEE' THEN 'OH' ELSE 'NA' END MARKET,
'MARCH_12' AS PERIOD,
COUNT (a.empl_id) head_count
FROM essbase.employee_pubinfo a
LEFT OUTER JOIN MMS_DIST_COPY b
ON a.cost_ctr = TRIM (b.bu)
INNER JOIN MMS_GL_PAY_GROUPS c
ON a.pay_group = c.group_code
WHERE a.employee_status IN ('A', 'L', 'P', 'S')
AND FISCAL_YEAR = '2012'
AND FISCAL_MONTH = 'MARCH'
GROUP BY a.company,
b.district,
a.cost_ctr,
c.category,
a.fiscal_month,
a.fiscal_year;
which gives me same rows with different head_counts. I am trying to combine the same rows as a total (one record). Do I use a subquery?Hi,
Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved.
Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
user610131 wrote:
... which gives me same rows with different head_counts.If they have different head_counts, then the rows are not the same.
I am trying to combine the same rows as a total (one record). Do I use a subquery?Maybe. It's more likely that you need a different GROUP BY clause, since the GROUP BY clause determines how many rows of output there will be. I'll be able to say more after you post the sample data, results, and explanation.
You may want both a sub-query and a different GROUP BY clause. For example:
WITH got_group_by_columns AS
SELECT a.empl_id
, CASE
WHEN c.category = 'E'
THEN 'Headcount Exempt'
ELSE 'Headcount Non-Exempt'
END AS accounts
, CASE
WHEN a.company = 'ZEE'
THEN 'OH'
ELSE 'NA'
END AS market
FROM essbase.employee_pubinfo a
LEFT OUTER JOIN mms_dist_copy b ON a.cost_ctr = TRIM (b.bu)
INNER JOIN mms_gl_pay_groups c ON a.pay_group = c.group_code
WHERE a.employee_status IN ('A', 'L', 'P', 'S')
AND fiscal_year = '2012'
AND fiscal_month = 'MARCH'
SELECT 'ST' AS ledger
, accounts
, market
, 'MARCH_12' AS period
, COUNT (empl_id) AS head_count
FROM got_group_by_columns
GROUP BY accounts
, market
;But that's just a wild guess.
You said you wanted "Help with count and sum". I see the COUNT, but what do you want with SUM? No doubt this will be clearer after you post the sample data and results.
Edited by: Frank Kulash on Apr 4, 2012 5:31 PM -
How to count and display the number of records in a database table
My webpage has a list of items and their details, every item has a button
Read / Make comments that loads the item in its own page displaying
a comments form and previous comments.
This is all working fine.
I would like to add to each item information stating how many comments have
been made about that item.
Allowing the user to see before hand if it is worth while clicking on the
Read / Make comments button.
Ideally each item will have a different number of comments.
The problem I have is outputing the number of comments associated with each item.
My comments table is called guest my items table is called titles.
I'm sure mysql statement is correct -
The table guest currently has 7 comments,
Item 1 has 3 comments
Item 2 has 2 comments
Item 3 has 1 comment
Item 4 has 1 comment
When I test the query in dreamweaver
$Recordset1 = "SELECT COUNT(guest.software_id) as COUNT, titles.id FROM titles LEFT JOIN guest ON titles.id = guest.software_id GROUP BY guest.software_id";
the outoput is a list showing 2, 3, 1, 1
My problem is, getting the totals into my repeat region.
I tried the following line
<td align="left" valign="top" bgcolor="#e5f8cb">Current comments:<?php echo $row_Recordset1['COUNT']; ?></td>
resulting in all comments so far displaying 0
I have highlighted in bold the parts that I am having difficulty with.
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
return $theValue;
$colname_rsTitles = "-1";
if (isset($_GET['id'])) {
$colname_rsTitles = $_GET['id'];
mysql_select_db($database_abe, $abe);
$query_rsTitles = sprintf("SELECT title, company, `description`, resources, location, url, image, keyword, copies FROM titles WHERE id = %s ORDER BY id ASC", GetSQLValueString($colname_rsTitles, "int"));
$rsTitles = mysql_query($query_rsTitles, $abe) or die(mysql_error());
$row_rsTitles = mysql_fetch_assoc($rsTitles);
$totalRows_rsTitles = "-1";
if (isset($_GET['id'])) {
$totalRows_rsTitles = $_GET['id'];
$colname_rsTitles = "-1";
mysql_select_db($database_abe, $abe);
$query_rsTitles = sprintf("SELECT title, company, `description`, resources, location, url, image, keyword, copies FROM titles WHERE id = %s ORDER BY id ASC", GetSQLValueString($colname_rsTitles, "int"));
$rsTitles = mysql_query($query_rsTitles, $abe) or die(mysql_error());
$row_rsTitles = mysql_fetch_assoc($rsTitles);
$totalRows_rsTitles = mysql_num_rows($rsTitles);
mysql_select_db($database_abe, $abe);
$query_rs_comments = "SELECT * FROM guest";
$rs_comments = mysql_query($query_rs_comments, $abe) or die(mysql_error());
$row_rs_comments = mysql_fetch_assoc($rs_comments);
$totalRows_rs_comments = mysql_num_rows($rs_comments);
mysql_select_db($database_abe, $abe);
$query_rs_users = "SELECT * FROM users";
$rs_users = mysql_query($query_rs_users, $abe) or die(mysql_error());
$row_rs_users = mysql_fetch_assoc($rs_users);
$totalRows_rs_users = mysql_num_rows($rs_users);
mysql_select_db($database_abe, $abe);
$query_Recordset1 = "SELECT COUNT(guest.software_id) as COUNT, titles.id FROM titles LEFT JOIN guest ON titles.id = guest.software_id GROUP BY guest.software_id";
$Recordset1 = mysql_query($query_Recordset1, $abe) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
mysql_select_db($database_abe, $abe);
if(!isset($_POST['softwareLevel'])){
if (!isset($_GET['class_id'])) {
//show all software titles
$query_rsTitles = "SELECT id, title, company, `description`, resources, location, url, image, keyword, copies FROM titles ORDER BY id ASC";
}else{
//show software titles filtered by Literacy of Numeracy (using URL GET variable)
$query_rsTitles = "SELECT id, title, company, `description`, resources, location, url, image, keyword, copies FROM titles WHERE titles.class_id = ". GetSQLValueString($_GET['class_id'], "int") ." ORDER BY id ASC";
}else{
//show software titles filtered by Level (using Form POST variable)
$query_rsTitles = "SELECT id, title, company, `description`, resources, location, url, image, keyword, copies FROM titles WHERE titles.level_id = ". GetSQLValueString($_POST['softwareLevel'], "int") ." ORDER BY id ASC";
$rsTitles = mysql_query($query_rsTitles, $abe) or die(mysql_error());
$row_rsTitles = mysql_fetch_assoc($rsTitles);
$totalRows_rsTitles = mysql_num_rows($rsTitles);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php $pagetitle="ABE Software Locator"?>
<html xmlns="http://www.w3.org/1999/xhtml" >
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $pagetitle ?></title>
<link rel="stylesheet" href="../../includes/styles.css" type="text/css" media="screen" />
<style type="text/css">
body {
background-color: #FFF;
</style>
</head>
<body>
<?php include("../../includes/header.php"); ?>
<div><table width="70%" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td width="29%" height="50" align="center"><a href="software_detail.php">Back to Locator</a></td>
<td width="50%" align="center"><a href="../../index.php">Welcome Page</a></td>
<td width="21%" align="center"><a href="../../logout.php">Log Out</a></td>
</tr>
<tr>
<td colspan="3" align="center"><strong> There Are <span class="totalrecordsnumber"><?php echo $totalRows_rsTitles ?></span> Software Titles Listed</strong></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<?php do { ?>
<table width="820" border="0" align="center" cellpadding="3" cellspacing="2">
<tr>
<td width="206" height="200" rowspan="3" align="center" bgcolor="#FFFFFF"><img src="images/<?php echo $row_rsTitles['image']; ?>" alt="<?php echo $row_rsTitles['title']; ?>" /></td>
<td colspan="3" align="center" bgcolor="#086b50"><h2><?php echo $row_rsTitles['title']; ?></h2></td>
</tr>
<tr>
<td colspan="3" align="center" bgcolor="#f6b824"><strong>Made by:</strong> <?php echo $row_rsTitles['company']; ?></td>
</tr>
<tr>
<td colspan="3" align="left" valign="top" bgcolor="#e5f8cb"><p class="ptaglineheight"><strong>Description: </strong><?php echo $row_rsTitles['description']; ?></p></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top" bgcolor="#e5f8cb"><span class="tabletext"><strong>Keywords</strong></span><strong>: </strong><?php echo $row_rsTitles['keyword']; ?></td>
<td colspan="2" align="left" valign="top" bgcolor="#e5f8cb"><strong>Resources:</strong> <?php echo $row_rsTitles['resources']; ?></td>
</tr>
<tr>
<td colspan="4" align="left" valign="top" bgcolor="#e5f8cb"><strong>Web Address:</strong> <a href="<?php echo $row_rsTitles['url']; ?>" target="_blank"><?php echo $row_rsTitles['url']; ?></a></td>
</tr>
<tr>
<td colspan="3" align="left" valign="top" bgcolor="#e5f8cb"><strong>Is installed on:</strong> <?php echo $row_rsTitles['location']; ?></td>
<td width="195" align="left" valign="top" bgcolor="#e5f8cb"><strong>Copies available:</strong><?php echo $row_rsTitles['copies']; ?></td>
</tr>
<tr>
<td colspan="3" align="left" valign="top" bgcolor="#e5f8cb"><a href="fulltitle.php?software_id=<?php echo $row_rsTitles['id']; ?>&id=<?php echo $row_rsTitles['id']; ?>">Read / Make Comments About This Software</a></td>
<td align="left" valign="top" bgcolor="#e5f8cb">Current comments:<?php echo $row_Recordset1['COUNT']; ?></td>
</tr>
</table>
<br />
<?php } while ($row_rsTitles = mysql_fetch_assoc($rsTitles)); ?>
</div>
<?php include("../../includes/footer.php"); ?>
</body>
</html>
<?php
mysql_free_result($rsTitles);
mysql_free_result($rs_comments);
mysql_free_result($rs_users);
mysql_free_result($Recordset1);I changed the mysql as you suggested GROUP BY titles.id
and added a while loop to iterate over the data
mysql_select_db($database_abe, $abe);
$query_Recordset1 = "SELECT COUNT(guest.software_id) as COUNT, titles.id FROM titles LEFT JOIN guest ON titles.id = guest.software_id GROUP BY titles.id";
$Recordset1 = mysql_query($query_Recordset1, $abe) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$row_Recordset1 = mysql_query($query_Recordset1) or die(mysql_error());
<td>Current comments:<?php
if($row_Recordset1)
while($row = mysql_fetch_array($row_Recordset1))
echo $row['COUNT'];
} ?></td>
The first item now displays the following,
comments:2311000000000000000000000000000
all others
comments:
the number matched the database table exactly, 30 records 4 of which have 2, 3, 1, 1 comments.
It looks as if the problem is trying to get the repeat region to pick up on it! -
How to count records from 2 tables and show in RDLC Report
hi all,
its being a one day searching for the solution but No Luck.
I have two SQL tables tblstudetail and tblfeereceiptdetail.
i just want to count records from both tables and show in RDLC report.
I tried SQl Query Like This:
select a.session, a.course,
Count(CASE a.ADstatus WHEN 'OK' THEN 1 ELSE 0 END ) AS Admission,
Count(CASE s .I_receiptstatus WHEN 'OK' THEN 1 ELSE 0 END) AS Feeprint
from
tblstudetail a
FULL join
tblfeereceiptdetail s on s.studentID = a.studentID
where a.session = '2015' AND s.Fsession = '2015' AND a.adcat = 'Regular'
GROUP BY a.session,a.course
ORDER by a.course
The result Show the Same Value in Both columns
Session Course Admission FeeDetail
2015 B.A. I 275 275
2015 B.A. II 307 307
2015 B.A. III 255 255
2015 B.Sc. I 110 110
2015 B.Sc. II 105 105
2015 B.Sc. III 64 64
Actully I want to Count How many ADMISSION have been Taken(FROM tblstudetail) and How many FEE RECEIPT have been Print (From tblfeereceiptdetail).
please guide me for this as soon as possible.
thanks in advance...I am counting 'OK' in both the table columns I.e 'ADstatus' in tblstudetail and 'feereceiptstatus' in tblfeereceiptdetail
please suggest me -
List of tables count and Views count in schema wise
Hi All,
I want to get all tables count and views count in Schema wise, What is the query for that?
Thanks in Advance.SELECT COUNT(*) FROM sys.tables t join sys.schemas s
on s.schema_id=t.schema_id
SELECT COUNT(*) FROM sys.views t join sys.schemas s
on s.schema_id=t.schema_id
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence
Maybe you are looking for
-
I get an error message when trying to install recommended update
I get an error message in many instances; cropping photo; editing photo; trying to caption a photo; unable to install Windows upgrade, etc.
-
Apple-unlocked iPhone became locked suddenly!!
I have an Apple-unlocked iPhone 3GS which I bought in Australia 2 years ago. It's always worked fine with various SIMs and varuious carriers - I travel a lot so unlocked was my chocie as I use SIMs in each country I visit. Recently in UK, I bought an
-
How do I get video clips from Windows 8 to mini ipad
How do I get video clips from Windows 8 to mini ipad
-
Why the ALV download Excel can't show all field title?
Dear All I have a problem for ALV download to Excel Example: the field title description has 11 len bits when I download Excel then the field title is u2018descriptiou2019 only 10 len bits. I found when the field value is more then 11 then
-
Extract User List from Security Manager
Hi, How to extract or export the list of users created in MII under Security Manager to some document like Excel. Regards, Adarsh