Query is counting twice
Hi all,
i loaded a cube, this bring 2 records FROM a ODS for example
Char KF
A 1
A -1
in the query the result is
Char KF
A 2
Why did this happen?, the result must be 1, the -1 must be omited, i dont know why and how can i solve this, please help
Do a listcube on the cube - then you will see the way records are getting aggregated....
In Listcube- disable DB Aggregation and check the same..
Similar Messages
-
How can i get a query to count a number of strings?
I want the query to count for me how many holidays there are to the USA in my table. But im not sure how to get it to retreive the result of a string or varchar2 datatype. This is what i have tried so far.
select count(COUNTRYVIS) <<this column contains all the countries visited
from "IT220_HOLIDAYDETAILS" <<this is the table where the column is
where COUNTRYVIS = "USA" << this is the result i want it to count
ORA-00904: "USA": invalid identifier <<this is the error message im getting, is there a way to count strings?
Thanks in advance!This has nothing to do with APEX. Please post basic SQL questions on the +{forum:id=75}+ forum.
In any OTN forum, alll code should be posted wrapped in <tt>\...\</tt> tags as described in the FAQ:
select count(COUNTRYVIS) -- this column contains all the countries visited
from "IT220_HOLIDAYDETAILS" -- this is the table where the column is
where COUNTRYVIS = "USA" -- this is the result i want it to countYou appear to be struggling with the distinction between identifiers and text literals. Hint: One uses double quotes, the other single quotes.
Note that quoted identifiers are generally not a good idea. -
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. -
Checkbox export values are counted twice?!
Hi there,
I'm experiencing problems while creating a simple PDF form.
I've created a table based list in InDesign and added checkboxes in the first cell of every line. When checked, the export value of the checkbox is being added to the total sum field at the end of the table.
Here is the file: http://www.schwanthaler-kunstschule.de/docs/Materialienliste2013.pdf
It all seemed to work pretty well untill one of our customers noted, that the values of some (not all!) checkboxes are counted twice.
Example: In the 9th checkfield ("Aquarellfarben 24 Stk. in Plastikkasten") the export value is 25, when checked there should be added 25 to the total sum field ("Insgesamt"). Instead there are added 50.
What's wrong here? I have absolutely no idea.
Would be great if someone could help here.
Thanks!
MaxIn fact, even if I don't understand the correlation between the field name and the double counted value, this SOLVED the problem!
I removed all of the german ä,ö,ü letters as well all the characters like dashes, dots, colons... and now it works like a charm!
Thanks a lot for your help! -
Computer short name counted twice in System Profiler
My Macbook Pro's Short Name is somehow being counted twice when I look in System Profiler. It shows (2) next to the name of my computer.
Any idea how to fix this?So, to rephrase my question:
Why is my user account being counted twice in System Profiler, like this: myusername (2)?
I I just went into my system profiler. I did:
Blue Apple > about this Mac > more info
this brought up the system profiler. I do not see a short user name here. I do see the computer name.
Could we have more info on where you see the short user name and what is our around it?
Robert -
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 -
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 to count differents values of a field
I have to do counts to the quantity of entitys in the database i have to obtain the quantity of registries for entities that appear
Buenas, les comento estoy trabajando con plsql y se me presenta un problema, necesito contar la cantidad de registros que devuelve la query por entidad, estoy trabajando con un procedure y evaluando con un cursor, pero no se como hacer trabajar la query para devolver ese valor
ENTITY OVERALL DATE HOUR
====== ===== ==== ====
ENT1 5 20100318 12:00
ENT2 20 20100318 12:00
ENT3 12 20100318 12:00
CURSOR1
SELECT distinct(rp.cod_entidad),
YYYYYYYYY,
to_date(to_char(SYSDATE,'YYYYMMDD'),'YYYY-MM-DD') as fecha_pago,
to_char(sysdate,'hh-mi-ss') as hora_pago
FROM registry rp, product pc
where pc.nro_solicitud = rp.nro_solicitud
and pc.resp_2= 'OK'
and pc.resp_1= 'OK'
Edited by: 862673 on 31/05/2011 10:01I must build a query to tell me how many records per entity is, YYYYYYY is not a field, i dont know that I write
TABLE
====
ENTITY Cliente telefono
====== ======= ========
ENT1 indiana 234 54231
ENT1 jose 566 78954
ENT1 esteban 234 1234
ENT3 juan 23434567
ENT3 jacinto 56745
ENT3 Perez 23467677
ENT2 indiana 678967
ENT1 jaime 234
RESULT
=====
ENTITY OVERALL
====== =======
ENT1 4
ENT2 1
ENT3 3
SELECT cod_entidad
, COUNT (DISTINCT yyyyyyyyy) AS overall
FROM registry rp,
product pc
where pc.nro_solicitud = rp.nro_solicitud
and pc.resp_2 = 'OK'
and pc.resp_1 = 'OK'
GROUP BY cod_entidad
Edited by: 862673 on 31/05/2011 13:41 -
Counter counts twice as many edges as it should, but correct frequency. Why?
Hi everyone,
I am using a PCI 6122 (S Series, DAQ-STC) and Labview 7.1 on a Windows XP. There are only two counters on this card (Ctr 0 and Ctr 1) and I need to use both of them to count edges. While testing the counters, I am inputing a TTL signal of 10kHz to the Gate of each counter, to be used as an external sample clock, and a 20Hz TTL signal into the Source of each counter, to be used as the input signal. Ctr 0 counts 40 edges per second, i.e. twice as many as it should, while Ctr 1 is reading the correct number of edges, i.e. 20 edges per second.
The strange thing is that when I switch the connections of Gate and Source for both counters to measure the frequency (or period), both counters read the correct frequency, i.e. 20Hz. To the best of my knowledge, both counters were reading the
correct number of edges a couple of weeks ago. Also, I have reset the
device several times but it does not make a difference. I am trying to figure out why this is happening and how to fix it, but I am no closer to answering either question. Does anyone have any suggestions?
Thanks.
Solved!
Go to Solution.After many tests on my own and after speaking with a NI engineer and repeating some tests over the phone, it seems like there is something wrong with the (one) counter on the board. I have sent it back for repairs (thankfully, it was still under warranty .
Message Edited by DanceWiz on 09-15-2009 09:58 AM -
SQL HELP NEEDED IN QUERY FOR COUNT
I Have this Query
SUM (CASE WHEN b.VET_OTHR_ELIG_CDE IN ('02', '03', '04') THEN 1 END) AS VET_YES,
SUM (CASE WHEN b.VET_OTHR_ELIG_CDE = '01' THEN 1 END) VET_NO, COUNT (E.ACTV_CDE) AS CNT_ACTV_CDE
Now i need to Add two more columns from the same Query Showing the count of VET_YES and VET_NO i.e count of TOTAL Veterans And TOTAL Non Veterans
those two columns i will be using as summary columns in my report.The bolded columns are those which i need to show the total column .anyone please help in this issue ..
ACTV_DESC ACTV_CDE VET_YES VET_NO CNT_ACTV_CDE
INACT DUE 13993 2 1 3
NOW I NEED TO MAKE IT LIKE THIS
ACTV_DESC ACTV_CDE VET_YES VET_NO CNT_VET CNT_NONVET CNT_ACTV_CDE (This is the total count)
INACT DUE 13993 2 1 2 1 3
Thanks in Advance,
Dev Kishore.T
Message was edited by:
Dev Kishore
Message was edited by:
Dev KishoreCheck this link.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/aggreg.htm#sthref1612
Regards
Raj -
QUERY WHICH COUNTS NUMBER OF TIMES WORDS/LETTER APPEAR IN SENTENCE - Thanks
I have this query below
it gives the number of times a txn is hign comfort and Approved
.. nyumber of times txn is meduim comfort and approved etc.
There is a futher line whihc shows the number of times txn is blacklisted BL COUNT.
I am trying to get line of query which can show me the number of times txn is approved, is high comfort and blcklisted ( the same applies for
wl - watch listed)
The query i am using
SUM
(CASE
WHEN cc.Comment
LIKE ('BL(%') and cc.Comment
LIKE ('Approved%')
AND cc.Comment
LIKE ('%ComfortLevel=High Comfort%')
THEN 1
ELSE 0 END)AS hbcl - NO RESULTS BEING GIVEN
pLEASE CAN ANYONE HELP,. THANKS
QUERY
USE RiskManagementReporting
GO
DECLARE
@StartDate DATETIME,
@EndDate DATETIME
SET @StartDate
= '2014-01-01 00:00:00'
SET @EndDate
= '2014-03-31 23:59:59'
SELECT
CONVERT
(VARCHAR(10),
mt.OPacket_TransactionTime, 102)
AS [Date],
SUM
(CASE
WHEN cc.Comment
LIKE ('Approved%')
AND cc.Comment
LIKE ('%ComfortLevel=High Comfort%')
THEN 1 ELSE 0
END) AS [A - HighC],
SUM
(CASE
WHEN cc.Comment
LIKE ('Approved%')
AND cc.Comment
LIKE ('%ComfortLevel=Medium Comfort%')
THEN 1 ELSE 0
END) AS [A - MediumC],
SUM
(CASE
WHEN cc.Comment
LIKE ('Approved%')
AND cc.Comment
LIKE ('%ComfortLevel=Low Comfort%')
THEN 1 ELSE 0
END) AS [A - LowC],
SUM
(CASE
WHEN cc.Comment
LIKE ('Declined%')
AND cc.Comment
LIKE ('%ComfortLevel=Low Risk%')
THEN 1 ELSE 0
END) AS [D - LowR],
SUM
(CASE
WHEN cc.Comment
LIKE ('Declined%')
AND cc.Comment
LIKE ('%ComfortLevel=Medium Risk%')
THEN 1 ELSE 0
END) AS [D - MediumR],
SUM
(CASE
WHEN cc.Comment
LIKE ('Declined%')
AND cc.Comment
LIKE ('%ComfortLevel=High Risk%')
THEN 1 ELSE 0
END) AS [D - HighR],
SUM
(CASE
WHEN cc.Comment
LIKE ('BL(%')
THEN 1 ELSE 0
END) AS [BL Count],
SUM
(CASE
WHEN cc.Comment
LIKE ('WL(%')
THEN 1 ELSE 0
END) AS [WL Count],
SUM
(CASE
WHEN cc.Comment
LIKE ('Marked as Touched%')
THEN 1 ELSE 0
END) AS [Touched by DRT],
COUNT
(mt.csnTransactionId)
AS [Sent to DRT]
FROM MatchedTransaction mt
WITH (NOLOCK)
LEFT
JOIN CustomerComment cc
WITH (NOLOCK)
ON (mt.csnTransactionId
= cc.SenderMTCN
AND cc.InsertDate
BETWEEN @StartDate AND
DATEADD (D, 1, @EndDate)I have adjusted this as
SUM
(CASE
WHEN cc.Comment
LIKE ('Approved%')
AND cc.Comment
LIKE ('%ComfortLevel=High Comfort%')
AND cc.Comment
LIKE ('%BL(%')THEN 1
ELSE 0 END)
AS hcbl,
Still no result -
Error in query with COUNT expression and Group By Clause
Hi
I have this query that when run gives me the following error:
SQL command not properly ended:
The code is as below:
SELECT
st_enrollment.student_id ,
ce_family_member.last_name ,
st_enrollment.grade_level ,
ce_family_member.DATE_OF_BIRTH ,
ce_family_member.GENDER,
at_hourly_attendance_records.ABSENCE_REASON_CODE,
at_hourly_attendance_records.CALENDAR_DATE,
COUNT(st_enrollment.student_id) AS days_absent
FROM
at_hourly_attendance_records,
ce_family_member,
st_enrollment
WHERE
st_enrollment.student_id = at_hourly_attendance_records.student_id
AND ce_family_member.student_id = st_enrollment.student_id
AND st_enrollment.school_id = 705
AND st_enrollment.school_year = 2006
AND st_enrollment.district_number = 1000
AND at_hourly_attendance_records.ATTENDANCE_STATUS = 'A'
AND at_hourly_attendance_records.CALENDAR_DATE < '16-MAR-06'
GROUP BY st_enrollment.student_id,
ce_family_member.last_name
st_enrollment.grade_level ,
ce_family_member.DATE_OF_BIRTH ,
ce_family_member.GENDER,
at_hourly_attendance_records.ABSENCE_REASON_CODE,
at_hourly_attendance_records.CALENDAR_DATE;
All suggestions are gratefully acknowledgment, Thanks in advanceThanks a lot. In fact I discovered it myself and I am immensely grateful to you for pointing the error..
-
SQL query to count number of VMs
In OVM 2.2 I could run a SQL query against the OVM database to count the number of VMs that I had created, for automated reporting purposes.
I've looked at the 3.1 OVM database and it looks like most of the data is kept in BLOB columns. So does anyone know how I might query the 3.1 database to count the number of VMs?
Thanks.Hi,
Combine the relevant data from the three tables (using UNION ALL) in a sub-query. without the GROUP BY.
Your main query can select from the sub-query's result set, as if it were a table. Do the GROUP BY in the main query.
That is:
WITH u AS
SELECT TO_CHAR (emp_start, 'YYYY') AS yr FROM Adminstaff
UNION ALL
SELECT TO_CHAR (emp_start, 'YYYY') AS yr FROM Clerk
UNION ALL
SELECT TO_CHAR (emp_start, 'YYYY') AS yr FROM ITstaff
SELECT COUNT (*) AS cnt
, yr
FROM u
GROUP BY yr
ORDER BY cnt DESC
;Since empno is the primary key, it's easier not to mention empno at all in the sub-query, and use "COUNT (*)" instead of "COUNT (empno)" in the main query. The results are the same.
It might be a little more efficient to GROUP BY in all three branches of the sub-query, and then to SUM the results in another GROUP BY in the main query. That means more code, of course, which I'll leave as an exercise for you.
Why do you have three separate tables? I can understand that nobody else wants to be near the IT Staff, but it seems like lots of things (including this job) would be a lot simpler if all employees were all in one table, with a column to designate to which group (Adminstaff, Clerk or ITStaff) each one belongs. -
Select query having count function is returning null
Hi Everyone,
Please see the query and help me to get this solved.
DB version
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
"CORE 10.2.0.1.0 Production"
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - ProductionQUERY
SELECT COUNT(*) as V_COUNT
FROM LAB_ORDER_TMPLT_TEST
WHERE TEST_ID IN
(SELECT WEST_TEST_ID
FROM TEST_CODE_CONVERSION TCC
WHERE TCC.EAST_TEST_ID = 2769)
GROUP BY LAB_ORDER_TMPLT_ID
HAVING COUNT(*) > 1;
It's returning null. Is there any way I can get the value as zero instead of null? Please help.Regards,
BS2012.Hi,
BS2012 wrote:
Hi Everyone,
Please see the query and help me to get this solved.
DB version
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
"CORE 10.2.0.1.0 Production"
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - ProductionQUERY
SELECT COUNT(*) as V_COUNT
FROM LAB_ORDER_TMPLT_TEST
WHERE TEST_ID IN
(SELECT WEST_TEST_ID
FROM TEST_CODE_CONVERSION TCC
WHERE TCC.EAST_TEST_ID = 2769)
GROUP BY LAB_ORDER_TMPLT_ID
HAVING COUNT(*) > 1;
It's returning null.
Really? COUNT never returns NULL; it always returns 0 or a positive integer.
Do you mean the query results in "no rows selected"?
Is there any way I can get the value as zero instead of null? Please help.Do you want a query that will produce the same output as the query above, but will produce a single row containing 0 when the query above does not produce anything? That sounds like a job for an outer join:
WITH original_query AS
SELECT COUNT(*) AS v_count
FROM lab_order_tmplt_test
WHERE test_id IN
( SELECT west_test_id
FROM test_code_conversion tcc
WHERE tcc.east_test_id = 2769
GROUP BY lab_order_tmplt_id
SELECT NVL (o.v_count, 0) AS v_count
FROM dual
LEFT OUTER JOIN original_query o ON o.v_count > 0
;If you'd care to post CREATE TABLE and INSERT statements for the sample data, then I could test this. -
Error in query with COUNT expression
Hi
I have a query that returns an error as follows:
"Column Ambiguously defined"
the code is as follows:
SELECT
ce_family_member.student_id ,
ce_family_member.last_name ,
st_enrollment.grade_level ,
ce_family_member.DATE_OF_BIRTH ,
ce_family_member.GENDER,
at_hourly_attendance_records.ABSENCE_REASON_CODE,
at_hourly_attendance_records.CALENDAR_DATE,
COUNT(at_hourly_attendance_records.student_id) AS days_absent
FROM
at_hourly_attendance_records,
ce_family_member,
st_enrollment
WHERE
st_enrollment.student_id = at_hourly_attendance_records.student_id
AND ce_family_member.student_id = st_enrollment.student_id
AND st_enrollment.school_id = 705
AND st_enrollment.school_year = 2006
AND st_enrollment.district_number = 1000
AND at_hourly_attendance_records.ATTENDANCE_STATUS = 'A'
AND at_hourly_attendance_records.CALENDAR_DATE < '16-MAR-06'
GROUP BY student_id; All help is highly appreciated. Thanks very much in advanceHi
I followed your suggestion. But I still get an error as follows:
Not a Group By Expression. And it points to the second line (ce_family_member)
SELECT
st_enrollment.student_id ,
ce_family_member.last_name ,
st_enrollment.grade_level ,
ce_family_member.DATE_OF_BIRTH ,
ce_family_member.GENDER,
at_hourly_attendance_records.ABSENCE_REASON_CODE,
at_hourly_attendance_records.CALENDAR_DATE,
COUNT(st_enrollment.student_id) AS days_absent
FROM
at_hourly_attendance_records,
ce_family_member,
st_enrollment
WHERE
st_enrollment.student_id = at_hourly_attendance_records.student_id
AND ce_family_member.student_id = st_enrollment.student_id
AND st_enrollment.school_id = 705
AND st_enrollment.school_year = 2006
AND st_enrollment.district_number = 1000
AND at_hourly_attendance_records.ATTENDANCE_STATUS = 'A'
AND at_hourly_attendance_records.CALENDAR_DATE < '16-MAR-06'
GROUP BY st_enrollment.student_id; Thanks a lot for your kind suggestions
Maybe you are looking for
-
Hello all, I could use some help with my iPhone 4, I hope this is the best place to ask! The Problem: I want to do a full backup of my iphone to either itunes or to icloud. Unfortunately the iphone got wet and isn't working properly. The phone turns
-
Unable to access Apps on HP Officejet Pro 8600 Plus
Hi guys, I can print wirelessly and print remotely using the ePrint apps on my iphone and ipad. Until recently, I have been able to access the apps, but this has stopped. I now get the following error message: "The printer was unable to connect to
-
Got what it takes to get me going?
Hi... As a newbie I need some help. I've been fighting with Borland Foundation 2005 to compile 2 samples from sun namely SerialDemo and JavaSoundDemo. I appear to get a blast of errors from the compiler. I can run the bytecode that is supplied and th
-
Html Editor in C# Windows Application
Hello, I am using WebBrowser Control in C# Windows Application,when I change the language from English to Japanese or Chinese,I am unable to type desired language text inside it. At the same time when I typed text in our forum text editor I am able t
-
How do I create a Search window in a RoboHelp HTML 8 topic pane?
I am working in RoboHelp HTML version 8 that is published as WebHelp. The system I am developing for has a search window as part of a skin that is available above the topic windows and is not always easily accessible. Can you create a search window t