Problem in finding the total count
my table as below:
ID code group cand
A 001 01 1
A 001 02 1
A 001 02 2
A 002 01 1
A 003 01 1
B 001 01 1
B 001 01 2
B 001 02 1
B 002 01 1
C 002 01 1
C 002 01 2
C 003 01 1
Here is what I want
ID Code tot_grp num_cand
A 001 4 3
A 002 4 1
A 003 4 1
B 001 3 3
B 002 3 1
C 002 2 2
C 003 2 1
where tot_grp is the total number of groups for each ID
and num_cand is the total number of candidates for each ID with that specific
code
Can I do it in one sql statement ?
Thank you
you said
where tot_grp is the total number of groups for each ID
and num_cand is the total number of candidates for each ID with that specific
code
Can u be more specific what should be present in tot_grp column.
Is it contains
a)sum of group for a given ID & code combination.
If yes then sql would be
select id,code,sum(group) tot_grp,count(cand) num_cand
from <table_name>
group by id,code
having the output ID Code tot_grp num_cand
A 001 5 3
A 002 1 1
A 003 1 1
B 001 4 3
B 002 1 1
C 002 2 2
C 003 1 1
2) Total No of groups(only the count) for a given Id & code
If yes then sql would be
select id,code,count(group) tot_grp,count(cand) num_cand
from <table_name>
group by id,code
having the output ID Code tot_grp num_cand
A 001 3 3
A 002 1 1
A 003 1 1
B 001 3 3
B 002 1 1
C 002 2 2
C 003 1 1
If none of the above condition is correct can u please be more clear .
Similar Messages
-
Help in finding the total count for each month
Hello everyone,
Sometime back I had posted about the date function. I have that problem solved now my problem is that after finding all records which against each record I need to find the total count for that month if no records than I have to set it to a 0.
Here is how my program has been written.
PROCEDURE extract_materials
IS
CURSOR xyz
BEGIN
FOR xyz1 IN xyz LOOP
-- once inside the loop for each of the record from
the cursor I need to find a total count for that record for everymonth in the year.
All these records will be instered in to a staging table
Can you please help me out with this. I really appreciate this.
Thanks in advance.
-VaniAndrew - you missed the tricky bit of the spec - include missing months with a zero.
You need to do an outer join to a select from any big table with a function involving rownum and add_months to generate all the possible months. However, its time to go home and I can't be bothered to work out the finer details. -
How do i find the total number of fields within all tables in one of my databases
I'm in the process of creating some "gee whiz" metrics for one of my applications and want to find the total number of columns contained in its database. Is there a stored procedure to get this information that would save me the effort
of opening each of my 66 tables and counting the columns? I also have the same question for my 138 views. Thank you for any ideas you care to offer...............Phil Hoop
Phil HoopHi Phil,
Assumes SQL 2005 or higher
Let 's try simple one ....
SELECT COUNT(col.column_name), col.table_name
FROM information_schema.columns col
JOIN information_schema.tables tbl
ON tbl.table_name = col.table_name
AND tbl.table_schema = col.table_schema
AND tbl.table_catalog = col.table_catalog
AND tbl.table_type = 'VIEW'
GROUP BY col.table_name
Let me know if this will help you.
If you think my suggestion is useful, please rate it as helpful.
If it has helped you to resolve the problem, please Mark it as Answer.
Varinder Sandhu www.varindersandhu.in -
Hi
I want some help from u guys to slove this problem
I want the Total Space in the Disk using the Java Pogram .
Atleast an idea how to solve this problem
Please can uguys provide me any idea .....soonSearch this board and you'll see that 43223 other persons had to find out that it's not possible in Java without using JNI.
-
How to find the total no of pages in script
hi
how to find the total no of pages in scriptHi
· &SAPSCRIPT-FORMPAGES&:
This field contains a number representing the total number of pages of the currently formatted form (any output between START_FORM and END_FORM). The page counter mode (START, INC, HOLD) of the individual pages is ignored. You can use this symbol to formulate information like
Page x of y for your output.
· &SAPSCRIPT-JOBPAGES&:
This field contains a number representing the total number of pages of all forms contained in the currently formatted print request, in other words, of all forms created using the OPEN_FORM, START_FORM.. ENDFORM, START_FORM.. END_FORM,..., CLOSE_FORM function modules.
When using the SAPSCRIPT-FORMPAGES or SAPSCRIPT-JOBPAGES symbols, SAPscript leads all output pages of the current form or current print request into main memory to replace the symbol by the appropriate value. For large output jobs, this can mean a very large amount of memory.
· &PAGE&, &NEXTPAGE&
This symbols are initially converted using the options specified in the form of the page definition.
Reward all helpfull answers
Regards
Pavan -
How do I find the total size of all my Music in iTunes 11?
I'm looking to get a new iPod, either a nano or Touch, so I'm trying to find the total size of all of my Music. Since iTunes 11's interface is so different from previous versions, I don't see a way to view that.
Ctrl B to show top menu
View Show Status Bar to show the grey bar at the bottom with the info you want.
While your there View> Show Sidebar and see if you prefer that. -
Introduction
We need to loop through all the flat files that have the same structure in a folder and import all the data to a single SQL Server table. How can we obtain the total count of the rows inserted to the destination SQL Server table?
Solution
We can use Execute SQL Task or Script Task to aggregate the row count increment for each iteration of the Foreach Loop Container. The following steps are the preparations before we add the Execute SQL Task or Script Task:
Create a String type variable FilePath, two Int32 type variables InsertRowCnt and TotalRowCnt.
Drag a Foreach Loop Container to the Control Flow design surface, set the Enumerator to “Foreach File Enumerator”, specify the source folder and the files extension, and set the “Retrieve file name” option to “Fully qualified”.
On the “Variable Mappings” tab of the container, map the variable FilePath to the collection value.
Drag a Data Flow Task to the container, in the Data Flow Task, add a Flat File Source, a Row Count Transformation, and an OLE DB Destination, and join them. Create a Flat File Connection Manager to connect to one of the flat files, and then configure the
Flat File Source as well as the OLE DB Destination adapter. Set the variable for the Row Count Transformation to “User::InsertRowCnt”.
Open the Property Expressions Editor for the Flat File Connection Manager, and set the expression of “ConnectionString” property to
“@[User::FilePath]”.
(I) Execute SQL Task Method:
In the Control Flow, drag an Execute SQL Task under the Data Flow Task and join them.
Create one or using any one existing OLE DB Connection Manager for the Execute SQL Task, set the “ResultSet” option to “Single row”, and then set the “SQLStatement” property to:
DECLARE @InsertRowCnt INT,
@TotalRowCnt INT
SET @InsertRowCnt=?
SET @TotalRowCnt=?
SET @TotalRowCnt=@InsertRowCnt+@TotalRowCnt
SELECT TotalRowCnt=@TotalRowCnt
On to parameter 1.
On the “Result Set” tab of the Execute SQL Task, map result 0 to variable “User::TotalRowCnt”.
(II) Script Task Method:
In the Control Flow, drag a Script Task under the Data Flow Task and join them.
In the Script Task, select variable InsertRowCnt for “ReadOnlyVariables” option, and select variable TotalRowCnt for “ReadWriteVariables”.
Edit the Main method as follows (C#):
public void Main()
// TODO: Add your code here
int InsertRowCnt = Convert.ToInt32(Dts.Variables["User::InsertRowCnt"].Value.ToString()
int TotalRowCnt = Convert.ToInt32(Dts.Variables["User::TotalRowCnt"].Value.ToString());
TotalRowCnt = TotalRowCnt + InsertRowCnt;
Dts.Variables["User::InsertRowCnt"].Value = TotalRowCnt;
Dts.TaskResult = (int)ScriptResults.Success;
Or (VB)
Public Sub Main()
' Add your code here
Dim InsertRowCnt As Integer =
Convert.ToInt32(Dts.Variables("User::InsertRowCnt").Value.ToString())
Dim TotalRowCnt As Integer =
Convert.ToInt32(Dts.Variables("User::TotalRowCnt").Value.ToString())
TotalRowCnt = TotalRowCnt + InsertRowCnt
Dts.Variables("User::TotalRowCnt").Value = TotalRowCnt
Dts.TaskResult = ScriptResults.Success
End Sub
Applies to
Microsoft SQL Server 2005
Microsoft SQL Server 2008
Microsoft SQL Server 2008 R2
Microsoft SQL Server 2012
Microsoft SQL Server 2014
Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.Hi ITBobbyP,
If I understand correctly, you want to load data from multiple sheets in an .xlsx file into a SQL Server table.
If in this scenario, please refer to the following tips:
The Foreach Loop container should be configured as shown below:
Enumerator: Foreach ADO.NET Schema Rowset Enumerator
Connection String: The OLE DB Connection String for the excel file.
Schema: Tables.
In the Variable Mapping, map the variable to Sheet_Name, and change the Index from 0 to 2.
The connection string for Excel Connection Manager is the original one, we needn’t make any change.
Change Table Name or View name to the variable Sheet_Name.
If you want to load data from multiple sheets in multiple .xlsx files into a SQL Server table, please refer to following thread:
http://stackoverflow.com/questions/7411741/how-to-loop-through-excel-files-and-load-them-into-a-database-using-ssis-package
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
How do I find the total number of elements in a multi dim array
How do I find the total number of elements in a single or multi dim array?
For example, a 2x3 array has 6 elements, and a 2x3x4 has 24. How do I compute this very easily - is there a single VI that does this?
David
Solved!
Go to Solution.Use "array size" (array palette) followed by "multiply array elements" (numeric palette)
(Works also equally well for 3D arrays and higher)
For a 1D array, just use "array size".
Message Edited by altenbach on 02-05-2009 05:57 PM
LabVIEW Champion . Do more with less code and in less time .
Attachments:
NumberOfElements.png 3 KB -
Is there a way to find the total "ON" time on my MacPro?
I was wondering if there was a way to find the total system "ON" time or usage time on my MacPro since I first purchased it?
I don't believe there is any recordation of that, but someone else may know better. There is, however, a record of how much time the computer has been in use since the last restart: open the Terminal application in the Utilities folder and at the prompt enter "uptime" (without quotes) and press RETURN.
-
How to find the total no of users in a client
Hi Techie's,
How to find the total no. of users in the client ? is it possible ?
i have tried out with the steps by viewing the table USR01,but i can't get the actual solution ?
solutions rewarded!
regards,
S.RajeshkumarHi rajesh,
You can use SU10, then click on "Authorization data" -> put * on user -> execute.. you should get a list of all users in the client with details included...
Also you can list them using USMM and check all licensed users....
Also SUIM -> users by complex selection criteria -> By user id -> put * on user -> execute.
Regards
Juan -
Find the total number of saved reports in Disco 10g using Disco Admin tool
Hi,
I am trying to find the total number of saved or scheduled reports in Discoverer 10g using Discoverer Administrator tool. Can anyone help?
Irene.The EUL STATUS workbooks might help
http://docs.oracle.com/html/B13916_04/eul_status.htm
HTH
Srini -
How do you find the word count on MacBook, please?
How do you find the word count on MacBook, please?
If you are trying to find word count in a Microsoft Word 2011 documemt, for instance, open the document and go to the Tools menu, selecting Word Count. In Apple's Pages application, open the document and look at the bottom of the page, near the left it will say "X Words" where X is the number.
Best of luck. -
Hi,
In my scenario if i give a range of document number(belnr) i have to fetch the details of the PO and have to find the totals of the PO from the history tab.
I have written the code as
gi_value and gi_amt are like table ekbe.
gv_total = 0.
LOOP AT gi_value WHERE vgabe = 1.
gv_total = gv_total + gi_price-dmbtr.
APPEND gi_value TO gi_amt.
ENDLOOP.
this code is working fine if i give only one belnr value.It identifying the total correctly.If i give 10 belnr values its finding the total of 10 belnr.In my scenario have to find the totals of each belnr based on PO number to do further coding.How to do so.Please help.Hi ,
Your requirement is not clear, you are taking the total in to GV_TOTAL field.
If you have 10 belnr numbers it will obviously add all the amounts .
Do you want amounts to be added for each PO. If so after each PO where do you want to place the total do u want to place it in any internal table?
what is the need of APPEND gi_value TO gi_amt statement in your code?
you are directly appending the content of gi_value table to gi_amt with out making any modifications in gi_valueit structure..
It is as good as below code.
gi_amt[] = gi_value [] .
Can you please make your requirement little more clear. -
How can I find the total word count in my entire Indesign CS3 document?
I have a book that consists of 10 different files and many many different text boxes. I need to find out what the total word count is for the entire book. Is there a simple way to do this, or do I have to copy and paste all the text from InD into a word file to get the number? Your help is much appreciated.
This AppleScript will get the total word counts of a folder of ID files—it shouldn't be too hard to convert to JavaScript if you are not using OSX:
tell application "Finder"
activate
set myFolder to choose folder with prompt "Select the folder containing the files to count"
set myFiles to every file of folder myFolder whose file type is "IDd5"
end tell
tell application "Adobe InDesign CS3"
set wordcounts to {}
set total to 0
repeat with j from 1 to (number of items in myFiles)
open item j of myFiles
tell active document
tell every story
set wordcounts to wordcounts & (count every word)
end tell
set totalstories to count every item of wordcounts
repeat with i from 1 to totalstories
set total to total + (item i of wordcounts)
end repeat
close
end tell
end repeat
display dialog "The documents in the selected folder have a total of " & totalstories & " stories, and " & total & " words"
end tell
========================================
If you just want the active document's count it would be:
tell application "Adobe InDesign CS3"
tell active document
set wordcounts to {}
tell every story
set wordcounts to wordcounts & (count every word)
end tell
set total to 0
set totalstories to count every item of wordcounts
repeat with i from 1 to totalstories
set total to total + (item i of wordcounts)
end repeat
display dialog "Total words in all " & totalstories & " stories: " & total
end tell
end tell -
Problem in finding the Duplicate as well as Non-Duplicate count
Hi,
I have a scenario where I have a table TABLEA which has 3 values
10 ABC
10 ABC
20 DEF
I want to pick up the duplicate count as wel as non duplicate count:
I have used the following query:
SELECT COUNT(*) FROM TABLEA A WHERE A.ROWID > ANY (
SELECT B.ROWID FROM TABLEA B WHERE
A.CODE=B.CODE)
But I am finding problem in getting the non-duplicate count .
Any help will be needful for me
Edited by: user598986 on Sep 23, 2009 11:32 PMuser598986 wrote:
Hi,
I have a scenario where I have a table TABLEA which has 3 values
10 ABC
10 ABC
20 DEF
I want to pick up the duplicate count as wel as non duplicate count:
I have used the following query:
SELECT COUNT(*) FROM TABLEA A WHERE A.ROWID > ANY (
SELECT B.ROWID FROM TABLEA B WHERE
A.CODE=B.CODE)
But I am finding problem in getting the non-duplicate count .
Any help will be needful for me
Edited by: user598986 on Sep 23, 2009 11:32 PMHi,
perhaps this query makes your job:
HR: XE > select * from test_;
NAME SALARY HIRE_DATE START_DAT END_DATE
15-SEP-09 15-SEP-09
15-SEP-09 01-DEC-09
john 27-AUG-09 16-SEP-09 16-SEP-10
28-FEB-09 20-SEP-09
Dave 2 17-JUN-08 16-SEP-09 02-JUL-11
1000 21-AUG-82 08-MAY-10
6 rows selected.
HR: XE > select count(hire_date), hire_date from test_
2 group by hire_date;
COUNT(HIRE_DATE) HIRE_DATE
1 27-AUG-09
1 21-AUG-82
2 15-SEP-09
1 28-FEB-09
1 17-JUN-08
HR: XE > select count(id), id from
2 (
3 select hire_date, 'simple' id from test_
4 minus
5 select test_.hire_date, 'simple' id
6 from test_
7 where test_.hire_date In (Select hire_date FROM test_ GROUP BY hire_date HAVING Count(*)>1 )
8 union all
9 select test_.hire_date, 'double' id
10 from test_
11 where test_.hire_date In (Select hire_date FROM test_ GROUP BY hire_date HAVING Count(*)>1 )
12 )
13 group by id;
COUNT(ID) ID
2 double
4 simple
HR: XE > Regards,
Ion
Maybe you are looking for
-
DNS not working for some computers
We have a SRP521W router and is set up with one SSID for wireless. In our office all the computers (5) can connect but only some may get on the internet. I have a laptop I am testing with and it will not connect, wired or wireless. I found an article
-
White Screen after freezing! Help
I just got a new ipod on boxing day and haven't used it very much. I was on Facebook tonight and it froze so I hit the sleep button and held it down, seeing if it would shut off. Instead of shutting off a white screen appeared. I looked up the soluti
-
Oracle error while creating pfile
SQL> startup nomount pfile='D:\ORACLE\product\11.1.0\db_1\database\initbbcomstage.ora'; ORA-27102: out of memory OSD-00026: additional error information O/S-Error: (OS 1455) The paging file is too small for this operation to complete.
-
Creating an Alert on a Parameter
Hello, I have a parameter that is defined as a range and I want to limit the user to only enter or select up to 4 enteries, how do I set up an alert to accomplish this? I have tried HasUpperBound with no success, any help will be greatly appreciated
-
Javax.servlet package does not exits
Hi all i have set my classpath as follows:- J2EE_HOME - c:\Sun\Appserver path - %JAVA_HOME%\bin;%J2EE_HOME%\bin set classpath- .;%JAVA_HOME%\lib;%J2EE_HOME%\lib\j2ee.jar my j2se path and classpath already set but after setting path and classpath for