Count(*) VS Count(ColumnName) VS Count(1)
Can some explain which one is better,
Count(*)
Count(ColumnName)
Count(1)
I think they are same, any one has any other opinion.
Count(*)
Count(ColumnName)
Count(1)
The diference that's
Count(*), check all table' columns of which can more slowly
Count(ColumnName), Only count data of especificaded column, no check null fields
Count(1), check only the table's column 1
The use depends on the sitacion, and therefore the best performance, depends on the proper use.
Similar Messages
-
Column count doesn't match value count at row 1, unknown number of columns
Hi,
I am making a program to read data from excel files as the above and store them in tables. I have managed to read all the data from excel files as a string and store them in a table.
ID Name Salary
50 christine 2349000
43 paulina 1245874
54 laura 4587894
23 efi 3456457
43 jim 4512878
But in my project I have several other files that have same cell that are blank as the above example
ID Name Salary
50 christine 2349000
43 paulina
laura 4587894
23 3456457
43 jim 4512878
and when i ran the same program i get this exception :
SQLException: Column count doesn't match value count at row 1
SQLState: 21S01
VendorError: 1136The code for creating the table and inserting the values is above:
private static String getCreateTable(Connection con, String tablename,
LinkedHashMap<String, Integer> tableFields) {
Iterator iter = tableFields.keySet().iterator();
Iterator cells = tableFields.keySet().iterator();
String str = "";
String[] allFields = new String[tableFields.size()];
int i = 0;
while (iter.hasNext()) {
String fieldName = (String) iter.next();
Integer fieldType = (Integer) tableFields.get(fieldName);
switch (fieldType) {
case Cell.CELL_TYPE_NUMERIC:
str = fieldName + " INTEGER";
break;
case Cell.CELL_TYPE_STRING:
str = fieldName + " VARCHAR(255)";
break;
case Cell.CELL_TYPE_BOOLEAN:
str = fieldName + " INTEGER";
break;
default:
str = "";
break;
allFields[i++] = str;
try {
Statement stmt = con.createStatement();
try {
String all = org.apache.commons.lang3.StringUtils.join(
allFields, ",");
String createTableStr = "CREATE TABLE IF NOT EXISTS "
+ tablename + " ( " + all + ")";
System.out.println("Create a new table in the database");
stmt.executeUpdate(createTableStr);
} catch (SQLException e) {
System.out.println("SQLException: " + e.getMessage());
System.out.println("SQLState: " + e.getSQLState());
System.out.println("VendorError: " + e.getErrorCode());
} catch (Exception e)
System.out.println( ((SQLException) e).getSQLState() );
System.out.println( e.getMessage() );
e.printStackTrace();
return str;
private static void fillTable(Connection con, String fieldname,
LinkedHashMap[] tableData) {
for (int row = 0; row < tableData.length; row++) {
LinkedHashMap<String, Integer> rowData = tableData[row];
Iterator iter = rowData.entrySet().iterator();
String str;
String[] tousFields = new String[rowData.size()];
int i = 0;
while (iter.hasNext()) {
Map.Entry pairs = (Map.Entry) iter.next();
Integer fieldType = (Integer) pairs.getValue();
String fieldValue = (String) pairs.getKey();
switch (fieldType) {
case Cell.CELL_TYPE_NUMERIC:
str = fieldValue;
break;
case Cell.CELL_TYPE_STRING:
str = "\'" + fieldValue + "\'";
break;
case Cell.CELL_TYPE_BOOLEAN:
str = fieldValue;
break;
default:
str = "";
break;
tousFields[i++] = str;
try {
Statement stmt = con.createStatement();
String all = org.apache.commons.lang3.StringUtils.join(
tousFields, ",");
String sql = "INSERT INTO " + fieldname + " VALUES (" + all
+ ")";
stmt.executeUpdate(sql);
System.out.println("Fill table...");
} catch (SQLException e) {
System.out.println("SQLException: " + e.getMessage());
System.out.println("SQLState: " + e.getSQLState());
System.out.println("VendorError: " + e.getErrorCode());
}To be more specific the error it in the second row where i have only ID and Name in my excel file and only these i want to store. The third row has only Name and Salary and no ID. How i would be able to store only the values that i have and leave blank in the second row the Salary and in the third row the ID? Is there a way for my program to skip the blanks as empty value?
Edited by: 998913 on May 9, 2013 1:01 AMIn an unrelated observation, it appears you are creating new database tables to hold each document. I don't think this is a good idea. Your database tables should be created using the database's utility program and not programmatically. The database schema should hardly ever change once the project is complete.
As a design approach: One database table can hold your document names, versions, and date they were uploaded. Another table will hold the column names and data types. Another table can hold the data (type for all data = String). This way, you can join the three tables to retrieve a document. Your design will only consists of those three tables no matter how many unique documents you have. You probably should seek the advice of a DBA or experienced Java developer on exactly how structure those tables. My design is a rough layout. -
The requested Performance Counter is not a custom counter...
Hello All,
I'm very new to both Oracle & .NET/IIS, and I am having trouble configuring one of my five IIS6/Win2003 servers. I have successfully deployed the same code on three other servers, each with the same ODAC (11.1.0.5.10 Beta) installation. Using sqlplus, I've been able to validate the connection to my db. There is even code using an older Oracle driver in part of the codebase that connects and works fine with the db, but I can't get my ODAC-reliant code to work.
When I try to access the code that uses ODAC, I get the error below.
Thanks in advance for any clues at all!
- Jason
The requested Performance Counter is not a custom counter, it has to be initialized as ReadOnly.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The requested Performance Counter is not a custom counter, it has to be initialized as ReadOnly.
Source Error:
Line 7: // Code that runs on application startup
Line 8:
Line 9: DashboardBusiness.WorkflowHelper.Init();
Line 10: }
Line 11:
Source File: d:\Inetpub\hhh.net\shared\iHHH\Dashboard\Global.asax Line: 9
Stack Trace:
[InvalidOperationException: The requested Performance Counter is not a custom counter, it has to be initialized as ReadOnly.]
System.Diagnostics.PerformanceCounter.Initialize() +1232
System.Diagnostics.PerformanceCounter..ctor(String categoryName, String counterName, String instanceName, Boolean readOnly) +110
System.Workflow.Runtime.PerformanceCounterManager.CreateCounters(String name) +70
System.Workflow.Runtime.Hosting.ManualWorkflowSchedulerService.OnStarted() +220
System.Workflow.Runtime.Hosting.WorkflowRuntimeService.HandleStarted(Object source, WorkflowRuntimeEventArgs e) +11
System.EventHandler`1.Invoke(Object sender, TEventArgs e) +0
System.Workflow.Runtime.WorkflowRuntime.StartRuntime() +835
DashboardBusiness.WorkflowHelper.Init() +95
ASP.global_asax.Application_Start(Object sender, EventArgs e) in d:\Inetpub\hhh.net\shared\iHHH\Dashboard\Global.asax:9
Version Information: Microsoft .NET Framework Version:2.0.50727.1378; ASP.NET Version:2.0.50727.1378I've never seen this error in the context of trying to connect via ODP.NET or ODT.
If you have Oracle Dev Tools for Visual Studio installed, you can try to create a connection to the database using Server Explorer. If this works, that means your ODP.NET connection is just fine.
If you don't have VS or the tools, another thing you can try is connecting through ODP.NET using a simple OracleConnection.Open. Make sure you have your client set up to connect to the DB server.
Here's some info about connecting to the DB:
http://download.oracle.com/docs/html/B28089_01/featConnecting.htm#sthref101 -
Buffered Edge Counting 20 MHz with duplicate count prevention
Dear all,
I went through the specs of several boards (M- series, S- and E- series, 6602 etc...). It seems that these boards can count edges with duplicate count prevention on at a maximum rate <= 20 MHz (i.e., 1/4 of 80 MHz) - but maybe I have misunderstood the docs.
Is there a NI board capable of buffered edge counting with a general purpose counter for random events going at rates from 0 Hz to > 20 MHz? Do I need to look for a reconfigurable board?
Thanks in advance.Dear Elizabeth,
Thanks for the answer.
In my application, events arrive asynchronously (actually, randomly). During the duration of a gate (namely, 1 microsecond), one expects anything from 0 to many (i.e., possibly more than 20, up to 80) events. This requires duplicate count prevention.
I may have misunderstood the specs for M series boards, but the document:
Using Duplicate Count Prevention for Counter Tasks in NI-DAQmx
from the NI web site, for instance, states that:
"All the other timebase edges that occur while the external source input is high are ignored. If no source edges are detected between two gate edges, as shown in Figure 3, duplicate count prevention ensures that pulse measurements return zero because the external source must be logic high to allow the internal timebase to increment the count register. This reduces your maximum source frequency to quarter of the original maximum (80MHz) timebase for NI-STC II and NI-TIO boards. Therefore duplicate count prevention should only be used if the frequency of the Source signal is 20 MHz or less.
Duplicate count prevention should only be use in the following situations:
Counter measurements
The counter Source is using an external signal (such as PFI x)
The frequency of the external source is 20 MHz or less
What's your take on that?
Thanks for your time. -
Record count per page , total record count per report in BI Publisher
hi,
In Oracle BI Publisher tool , can you please tell me how to display total record count of a report ? as well as how to display record count per page ?
Thanks for your help
Regards
Gayathricheck inbox. forwarded the updated template
-
Count digital events on a Counter with pci-6602 with callback on CVI
Hi,
I'm using a PCI-6602 card with CVI 8.5 and I need to trig on event.
On every pulse I received, I need to do some actions like increasing a counter, send a message on Rs232 etc.. I don't want to do any loop checking that the counter value has changed. I would like to use a callback to execute this code only on the edge or counter value event.
My problem is that I don't know which function can do this. Is there any way to get an event on a pci-6602?
Thanks
James
Solved!
Go to Solution.Hello.
It's completely possible to create a callback that will allow you to do what you want when a edge will occur on an external signal you define.
To do this, you can for exemple create a counting edges task that will use one of the 6602 counters,and the set your external signal to be the source of your sample clock.You'll then be able to register a callback with the function DAQmxRegisterSignalEvent, and your callback will be called each time an edge will occur on your specified sample clock source.
Here's 2 links that explain the events in DAQmx and how to handle them in CVI. The example ReadDigChan-ChangeDetectionEvent.pr that ships with DAQmx examples (Hardware Input and Output<<DAQmx<<Digital measurements) can be very useful to understand how to do. This example creates a signal event callback to detect change detection for digital inputs.
Regards. -
Dynamic Counter in BEx Report to count the drilldown line item.
Hi,
I have a requirement to show the count of different parts in a report. For example the report,
Part Number Costs
100 200 $
and if you drill down from the part number to line item details, you will get,
Item Number Costs
10 50 $
20 50 $
30 50 $
40 50 $
So basically Part Number 100 is consists of 4 Item numbers. Now I want to show original report like this,
Part Number Costs Counter
100 200 $ 4
Is there any way I can catch that counter, like how many line item is there per Part Number ?
I am thinking of 2 ways, Virtual key Figure to calculate this or in alternate if possible use the Classification extractor (not sure if it possible to count the number of items per classification extractor though).
Is there any better or simpler way to deal this without changing the cube structure ?
Thanks for your time spent on this,
Kind Regards,
ArpanHi,
You can get this functionality with Virtual Key figures.
You will have the complete dataset in the RSR00002 Enhancement in CMOD.
Thank you
Arun -
Problem to get count from resultset with select count(1) like query
Hi,
The snippet of code is like this ...!
preparedStatement = connection.prepareStatement("select count(1) as count from acf_users where acf_user_name like ? and acf_user_password like ?");
preparedStatement.setString(1,stringUsername);
preparedStatement.setString(2,stringPassword);
resultSet = preparedStatement.executeQuery() ;
System.out.println("The ResultSet Count checkUser() : "+resultSet.getString("count"));
preparedStatement.close();
But there is a SQLException like :
java.sql.SQLException: ResultSet.next was not called
I want to extract and check the count in the program..
Does anyone has the solution, comments on this.
Thanks in Advance,
-SachinThanks a lot to have a look on it :
I got the solution on it as :
preparedStatement = connection.prepareStatement("select count(*) as total from acf_users where acf_user_name like ? and acf_user_password like ?");
preparedStatement.setString(1,stringUsername);
preparedStatement.setString(2,stringPassword);
resultSet = preparedStatement.executeQuery() ;
resultSet.next();
System.out.println("The ResultSet checkUser() : "+resultSet.getInt("total"));
The important line is :
resultSet.next()
Thanks once again,
Sachin ! -
Invalid values for negative counts using DAQmxReadCounterF64 for edge counting
I am seeing this issue with using DAQmxReadCounterF64 with
simple edge counting. If the counter reads a negative count value, it
returns a number that looks like an unsigned 32-bit number rolled over
(~4294967295).
I am using DAQmx v8.9.5. PXI-6602 with Windows XP, programming in C++.
Is this a bug in the driver?Hi Mroche,
You're correct that the number you are seeing is the rollover of an unsigned 32-bit integer. Newer DAQ products use a 32-bit count register (e.g. M Series, TIO, X Series). In this register, the value -1 is represented the same as 232-1.
I wouldn't call this a bug exactly. The value you are reading is what is in the count register, and I don't think it makes sense to necessarily assume that 4294967295 should be scaled to -1 for all cases. Making this assumption would result in undesired behavior for anybody trying to count to 231 or higher (at which point the count would roll over to -231).
Having said that... position measurements are treated differently starting in DAQmx 9.0 due to the behavior reported on another thread which was in fact deemed a bug (which I notice you have seen already). The driver casts the raw count to I32 before scaling it to a position.
Now, I'm not so sure it makes sense to treat the two measurement types differently, but I think the reasoning behind the decision was that negative values make sense when talking about position, but for counting edges not quite as much (what exactly is a negative number of edges?). In the count edges case, I think it makes the most sense for DAQmx to allow the user to handle rollovers himself. At the end of the day, all the driver can do is change where the rollover occurs (either at 0 = 232 or 231 = -231).
In your case, if you want to read (-) values on your count edges task, the easiest way to accomplish this is to read the data back as U32 (DAQmxReadCounterU32) then type cast it to I32. This will give the result that I think you are looking for.
If you have any suggestions to help improve usability, please feel free to post to the DAQ Idea Exchange. Some preliminary ideas to make this experience a little more intuitive might include a property node to set how the data is cast, or perhaps have the driver cast the data to I32 if the Count Direction is set to anything other than Count Up. Although, the 2nd idea has the potential to break existing applications so it might not be as viable of an option.
Best Regards,
John Passiak -
I have a tablix grouped on column a and detailed on column b.
I am trying to count the rows in 3 separate ways.
CountDistinct(Fields!A.Value) =work perfectly on group column
CountDistinct(Fields!B.Value) = work perfectly on the detail column
But now I was
Count(Fields!A.Value) = on the group column but I get all the detailed count 13 instead of just the group count of 4.Hi Giss68,
Based on my understanding, you want to calculate the count of the group fields, right?
In your scenario, if you use Count(Fields!A.Value), the expression returns a count of specified values evaluated in the dataset scope. So it’s expected that you get count of all Fields!A.Value instead of grouped fields. Since you want to calculate the count
of grouped column fields, you should use CountDistinct() function.
As we tested in our environment, we specify the expression with CountDistinct() function, we can get expected result.
Reference:
Count Function (Report Builder and SSRS)
CountDistinct Function (Report Builder and SSRS)
If you have any question, please feel free to ask.
Best regards,
Qiuyun Yu
Qiuyun Yu
TechNet Community Support -
INVALID VOLUME FILE COUNT and INVALID VOLUME DIRECTORY COUNT
Every few days, something on my machine is causing an invalid volume file count and an invalid volume directory count. Error message will read something like:
Invalid volume file count
(it should be 520176 instead of 520178)
Invalid volume directory count
(it should be 152750 instead of 152748)
This causes the machine to lock up.
This is my SECOND machine (same set up on the previous machine) that is experiencing these issues. Once I run the disk utility off of the original OS disk everything is fine.This is my SECOND machine (same set up on the previous machine) that is experiencing these issues. Once I run the disk utility off of the original OS disk everything is fine.
Invest in a couple things - backup drive, Disk Warrior, and SuperDuper
Install OS X to part of your external (small and just big enough for an emergency system and minimal programs).
Booting off DVD is fine, but no Finder and you are limited to the (older) version of Disk Utility on there (and it does get updated and changed).
Clone your system for boot backup, especially before updates and changes.
Disk Warrior recognizes and repairs more issues, some of which Apple First Aid doesn't even look for.
So even though it appears okay afterward...
Next would be to run Apple Hardware Test, and along with that check your RAM with MEMTEST (REMBER is handy and is just GUI wrapper to memtest program) or run Memtest yourself from the Terminal. -
Read Counter/Position Line or Volume Counter
I have the iPod Nano 4 GB.
Serial # YM538AJCTK3
It used to show the read counter or position line that shows at which point on the song/podcast I'm on; or the.
Now, it's not showing it. Instead it's showing 5 small circles that doesn't indicate the position of the song/podcast nor the volume counter.
I can't seem to change this setting back.
Please help.Sometimes, if you don't allow the screen to refresh before pressing another button, it gets stuck.
See this for help.
iPod "stuck" on the artwork or rating screen.
As you will see, updating the software can cure this. -
No counter display on my bpm counter plugin.
When I insert the bpm counter on a track, it doesn't show a display for a counter like I've seen on every tutorial I've looked at. All it shows is a menu with the following: "Measured BPM," "State," and "Reset." It's driving me mad, and no tutorial I've seen addresses this, making me think it's just my Logic that has this problem. I've only had Logic for about a week, so maybe I'm doing something dumb, here...
When I insert the bpm counter on a track, it doesn't show a display for a counter like I've seen on every tutorial I've looked at. All it shows is a menu with the following: "Measured BPM," "State," and "Reset." It's driving me mad, and no tutorial I've seen addresses this, making me think it's just my Logic that has this problem. I've only had Logic for about a week, so maybe I'm doing something dumb, here...
-
Counter base maintenance and multiple counter maintenance
Hi
With refering to the counter base order generated in the system, i have confused.
We have the plans 100, 200, 300 to max 2000 Hours. The task lists are assigned. The maintenance plan annual estimate is 4000 Hours (i dont know why its required if the measurment documents are in use) ..
The system is regularely generating the orders eventhough we have measurement docuements upto 300 Hours. Last week we have no measurement updates.
Can you give me the logic, functionality of the performance maintennace. I have read SAP help which is not explaining in practical manner.
Also how to work for multiple counter maintenance. We have to do for DAY (30 Days, 60 days. 180, 360 Days) Wise or Hour wise (300, 900, 1500, 3500, 7000 Hours maintenance. Can you tell me how to work for this on single maintennace plan..since our equipment also only one.Hi,
This appears to be a typical multiple counter plan situation consisting of performance based and time based elements. The performance cycles are based on operating hours and time is the elapsed days.
The relevant section of SAP Help is - [here|http://help.sap.com/saphelp_erp60_sp/helpdata/en/d8/e06a1f7e9c144fbb3a3ed0c38bc38a/frameset.htm]
See point 3-Scheduled date calculation. In particular:
The annual performance recorded for the counters and the most up-to-date counter reading are used to calculate the corresponding planned date.
Annual Estimate is used to calculated planned date meaning that calls can occur before the actual counter readings are reached.
-Paul -
May I change counter parameter while it is counting?
Hi all.
I'm using CVI 7.1 and traditional daq with a PCI-6601 board to perform simple event counting to count delays on some tested devices
For my application I need to change the type of counting from ungated to gated while the counter is running: is it possible?
My application is configured this way:
GPCTR_Set_Application (1, ND_COUNTER_0, ND_SIMPLE_EVENT_CNT);
GPCTR_Change_Parameter (1, ND_COUNTER_0, ND_SOURCE, ND_INTERNAL_100_KHZ);
GPCTR_Control (1, ND_COUNTER_0, ND_PROGRAM);
Now, while the counter is running I need to follow on counting only if the gate signal is high. If I simply use
GPCTR_Change_Parameter (1, ND_COUNTER_0, ND_GATE, ND_PFI_38);
I receive the error that "The specified resource is already armed", so I tried with
GPCTR_Control (1, ND_COUNTER_0, ND_DISARM);
GPCTR_Change_Parameter (1, ND_COUNTER_0, ND_GATE, ND_PFI_38);
GPCTR_Control (1, ND_COUNTER_0, ND_ARM);
but the counter continues counting regardless the state of the gate signal. That's why my question: how can I perform this task?
(Note: if configured from start for gated counting, the counter operates regularly based on gate state)
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos?Kevin, in my application I am monitoring a long-lasting process (approx. 45 seconds long) in which I must measure the time a contact is on. 6601 card is dedicated to measure this time: the contact is used as the gate signal of the counter so that time measurement is exactly related to the process being surveyed. The problem is that during part of this process I cannot be connected to the actual contact, so I cannot use its state as the gating signal during all time.
I was hoping that I could change counter configuration on the fly so that I can start counting based on the gate, switch to ungated counting while I cannot survey the contact and switch back to gated at the end of the interval, when I can use again the contact as counter gate.
In the meanwhile I am monitoring some other parts of the process and acquiring measures on serial (that is intrinsically "slow") devices: due to this sum of processes going on inside the computer, I cannot rely of my program being enough fast as to monitor the state of the DUT and mirror it in a gating signal.
I have tested my solution to sum up partial timer counts and found it not so easy to manage so I decided to introduce a little hardware modification in the measuring system and OR the gating signal with a digital output of the 6601: I can manage in the software to drive this signal with significant margin on actual phenomenon, so that I am now using the counter always in gated mode. This solution is more or less in the way of your last answer seem we arrived at it contemporarily!
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos?
Maybe you are looking for
-
I revamped my computer with all new hardware and installed Firefox. I found that it was taking 3 tries to get the window to stay up and not crash immediately. This has been ongoing for a few months. For no reason that I can see (I have not downloaded
-
Device only connnected the first time..please help
ok so i was able to transfer some songs to my zen microphoto one time. ever since then i get a device not connceted when i try to use it.... ok so i removed the usb controller and then restarted the computer.then when it was restarted i plugged in th
-
How to change the length of time calendar retains appointments
On my previous Blackberry running OS7, I was able to change the length of time the calendar kept appointments, but I can't find that setting on my Q10. I would like to be able to keep appointments on the calendar indefinitely. Thanks for any advice.
-
How to keep width of columns displaying hard drive contents?
When one double clicks on the hard drive it opens on the desktop with the various columns displaying folders. I know how to widen the columns in order to read folders with long names, but how does one KEEP them that width? Every time I open my hard d
-
OS X Mavericks cannot be installed on Macintosh HD
Macbook - Mac OS X Lion 10.7.5 34.5 GB free out of 159.18GB When I try and download Mavericks it says, "OS X cannot be installed on 'Macintosh HD'." I am unable to delete the backups.backupdb file as it says "...unexpected error occurred (error code