Query to find customers with cents only
Can anyone please help we write a query, where I can identify customers who only have cents in the net amount (eg $100.01 or $315.20)?
Thanks!
or
SQL> select t.amount
2 from (select 123.40 amount
3 from dual
4 union
5 select 8324 amount
6 from dual
7 union
8 select -1 amount
9 from dual) t
10 where instr(t.amount,'.') > 0;
AMOUNT
123.4
SQL>
Similar Messages
-
Query to find customers who have not purchased anything
I have a query to find customers who have purchased what we call consumables (using item property) over a given period:
SELECT T0.CardCode, T0.CardName, T0.DocDate, T0.DocTotal, T1.ItemCode, T1.Dscription,T1.quantity, T2.ItmsGrpNam
FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry, OITG T2
WHERE T0.DocDate BETWEEN '[%0]' AND '[%1]' AND T1.ItemCode like '2ssy%' AND T2.ItmsGrpNam = 'consumable'
I have another to show customers who have a particular type of equipment:
SELECT T0.manufSN,T0.itemName, T3.Name, T2.Address, T2.Street, T2.Block, T2.City, T2.County, T2.ZipCode
FROM OINS T0 INNER JOIN OCRD T1 ON T0.customer = T1.CardCode INNER JOIN CRD1 T2 ON T1.CardCode = T2.CardCode Inner Join OCPR T3 ON T0.ContactCod = T3.CntctCode
WHERE T0.manufSN like 'P%' AND T2.AdresType= 'S'
What I would like is to find those customers who have this equipment (query 2) but who have NOT purchased and consumables in say the last year.
I have tried using Excel by finding duplicates and taking those in query 1 from those in query 2 but it's very messy.
Has anyone done anything like this or got any good ideas?
ThanksHi Ralph,
Well, I enjoy teaching, so let's start at the beginning. SQL is a fairly full-featured language, and it supports recursion and nesting. That's why the books online often describe elements of the SQL statements as "expression" - it may be more than a field or a simple function occurring there. Nesting is the little puppy we used here.
Now, in your first post, you said: "What I would like is to find those customers who have this equipment (query 2) but who have NOT purchased and consumables (query 1) in say the last year."
So, our common point between the two queries is the customer, the CardCode. That's what this part does: F0.CardCode = T0.Customer. In my internal convention, I used F for Filter. So we only want the results in the filter where the CardCode matches the CardCode/Customer from the main query tables. It's the sole contact point between the two queries.
You also said you wanted only the items where they had purchased no consumables, which basically translates into: a count of the records equals 0. Now, since all we're interested in from the second query, the consumables query is how many records we returned, we get rid of all the columns except for one that we apply a COUNT to. After that, it's a simple criteria: the result of the second query has to equal 0. This is how the criteria looks after you take out all the details and put only the important brackets in: (SELECT COUNT...FROM...WHERE...) = 0.
This might be confusing at first, because most of the time we return recordsets from queries, but a standard feature of SQL is to return a value of any data type if the query returns a single row and a single column. This wouldn't work at all if we had more than one column in our nested query (or would require lots of tweaking), and although it returns a number of results in the complete process of the whole SQL statement, it only returns one result for each row.
Regards,
Mark Dielmann
Edited by: Mark Dielmann on Nov 13, 2009 12:30 PM - Forum doesn't support advanced formatting on answered questions.
Edited by: Mark Dielmann on Nov 13, 2009 12:32 PM - Salutations and more formatting.
Edited by: Gordon Du on Nov 13, 2009 10:35 AM - There are maximum characters limitation for correct format -
Query showing all customers with or without transactions
The content of the cube are all customers with transactions only. I want to create a report that will display all the customers with or without transactions. I tried to create a multiprovider combining the sales cube and customer master data. I created a query but it only displays the customes with transactions. Is there any other way wherein i can generate a report showing all customers with or without transactions?
hi,
the same problem happened, but no update whether it's solved, 'selection constant' should work
Multiproviders and filter on time
the link mentioned should be this
http://help.sap.com/saphelp_nw04/helpdata/en/e7/5f983c1a356858e10000000a114084/content.htm
Re: Determining NULL records -
Query to find records with more than 2 decimal places
I have written the below query to find records with more than 2 decimal places, but it is returning records with decimal places 1 & 2.
The datatype of the AMT column is NUMBER (without any precision).
SELECT amt FROM amount_table
WHERE substr(amt, instr(amt, '.')) LIKE '.%'
AND length(substr(amt, instr(amt, '.') + 1)) > 2Output:-
AMT
*41591.1*
*275684.82*
*64491.59*
*3320.01*
*6273.68*
*27814.18*
*30326.79*
131.8413635
162.5352898
208.5203816
8863.314632
22551.27856
74.716992
890.0158441
2622.299682
831.6683841
*1743.14*
2328.195877
3132.453438
5159.827334
3.236234727
37.784
ThanksOracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
create table amount_table
LINE_NUMBER NUMBER not null,
FEE_AMT NUMBER not null
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (60208, 41591.1);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (60213, 275684.82);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (60238, 64491.59);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (63026, 3320.01);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (59906, 6273.68);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (83111, 27814.18);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (83114, 30326.79);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112395, 131.8413634682);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112399, 162.5352898104);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112402, 208.5203815738);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112403, 8863.3146321954);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112406, 22551.2785551322);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112407, 74.716992);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112410, 890.015844079);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112411, 2622.2996817048);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112414, 831.6683840698);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112415, 1743.14);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112418, 2328.1958771886);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112419, 3132.4534379886);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112422, 5159.8273341686);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112423, 3.2362347266);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112426, 37.784);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112427, 198.7423503696);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112430, 0.7220848332);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112433, 12.4149375254); -
Advice with a query to find Accounts with activities within a given period ONLY
Hello there,
I am relatively new to Microsoft T-SQL and I was wondering if someone could help shed some light into a requirement I got...
I have two tables in a database. One with accounts, and another with activities for such accounts. He is a simple diagram:
*NOTE: Dates are in the DD/MM/YYYY format.
Here is what I need to do:
I need to get a list of all the accounts where the LAST activity was created in a date range, along with a count of activities that fall in such range. The idea behind this is to find out accounts with no activity after a certain period.
I can certainly accounts with activities in a given range -- but that does not mean that there was no activities after the range.
For example, if I look for Accounts with activities between Feb/2014 and Mar/2014, this query should NOT return the Contoso account, because it ha an activity after Mar/2014 (i.e.: Meeting with John on 15/Apr/14).
Another example: If I query accounts with activities from 01/Jan/2014 and 03/Apr/2014, it should ONLY return the Adventureworks account:
Adventureworks (3)
[the number in parenthesis is the count of activities in that given time]
This is because all other accounts had activities after 03/Apr/2014.
Could someone please advise the best way to construct this query?
Thanks in advance for the help!
Regards,
P.SELECT * FROM tbl WHERE CreatiinDate BETWEEN @firstactivities AND lastactivites
AND NOT EXISTS
(SELECT * FROM tbl t WHERE CreatiinDate>=@lastactivites
AND
tbl.AccountID=T.AccountID )
OR
SELECT * FROM tbl WHERE
AccountID NOT IN (SELECT
AccountID FROM
tbl t WHERE CreatiinDate>@lastactivites)
AND CreationDate BETWEEN
@firstactivities AND lastactivites
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 -
Backend query to find metrics with thresholds
Hi,
Is there a way to query the backend tables in repository database to find the metrics with thresholds on a database.I want to findout the missing warning/critical thresholds for all the targets.Any inputs for this may be helpful to me.
Thanks.You might want to create a User Deinfed Metric that does a query on the SYSMAN schema to find out.
Checkout
Oracle® Enterprise Manager Extensibility Guide
10g Release 5 (10.2.0.5)
http://download.oracle.com/docs/cd/B16240_01/doc/em.102/b40007/toc.htm
For description of all SYSMAN views to select your data
Regards
Rob
http://oemgc.wordpress.com -
Query Data Finder Server with ActiveX
I haven't been able to find much resources on how to use ActiveX to Query a Data Finder Server. I know that this is all supposed to be done with the ToCommand but I have no idea how it is done beyond this. Can someone give me some direction as to what commands are needed to Open a Data Finder, Create a Query, Merge Queries, and get resulting file paths?
Thanks,
David VanleeuwenHi Djvanlee,
So they are not ActiveX commands, you would use VBScript Commands with a ToCommand reference writing to DIAdem through invoke nodes. Are you using LabVIEW with the ToCommand reference?
An example of this can be found by opening up the DIAdem - Example Finder by going to Help>>Examples and it will be on the Context tab under the directory Examples>>Create Scripts>>Using Interfaces>>Controlling DIAdem from LabVIEW. Then the commands can be found in the DIAdem Help on the Contents tab by going to Programming Reference>>Object Oriented Script Interfaces>>DIAdem NAVIGATOR>>Methods. The methods you would reference are labeled as <DataFinder>. It looks like the main commands you would need are:
ConnectDataFinder()
CreateQuery()
Load Query()
SaveQuery() \\Note when you save the query you will have to indicate the path.
If you are looking for a good example of programmatically using the DataFinder in the script tab in DIAdem you can find this in the ExampleFinder on the Contents tab at "Extending Functionalities with Scripts>>Context Menu for the Search Results of the DataFinder". The ResultsList_Menus_Add.VBS connects to the DataFinder programmatically and loads a query.
Peter T
Applications Engineer
National Instruments -
Query to find tables with excessive initial extent settings
After loading a database dump we found many tables occupying large space due to large initial extents storage parameter but with very few rows and am trying to determine if it would be worth the effort to reorganize the entire schema. In other words, we are looking for a query to compare the estimated actual space that would be occupied by the table rows vs. the current size to see the space savings if we were to reorganize.
I hacked out a script to calculate the estimated size using the table stats (or 64K if estimate is lower) and compared that vs. the extents allocated to each table but this seems a rather inexact way of doing it. Is there a more accurate approach?
Doing this on Oracle database 10.2.0.4 on Windows Server 2003 SE
SELECT a.table_name,
b.table_size_MB,
ROUND((a.num_rows * a.avg_row_len) / (1024 * 1024),2) calc_size_MB,
b.table_size_MB - GREATEST(ROUND((a.num_rows * a.avg_row_len) / (1024 * 1024),2), 0.0625) savings_MB
FROM dba_tables a,
(SELECT segment_name, sum(bytes)/(1024*1024) table_size_MB
FROM dba_extents
WHERE tablespace_name like 'PMDX' and segment_type = 'TABLE'
GROUP BY segment_name) b
WHERE a.owner = 'CAS' and a.table_name = b.segment_name
ORDER BY b.table_size_MB desc
TABLE_NAME TABLE_SIZE_MB CALC_SIZE_MB SAVINGS_MB
TPM06_POL_DATA_WRK_PREV 640 493.46 146.54
TPM06_POL_DATA_WRK_CURR 640 496.57 143.43
TPM06_POL_DATA_201006 640 496.8 143.2
TPM06_POL_DATA_201005 640 494.87 145.13
TPM06_POL_DATA_201004 640 490.45 149.55
TPM07_MOV_DTLS_WRK 256 198.66 57.34
...Hi,
Didn't you check the dba_extents view with respect to the tables which you estimated.
After loading a database dump we found many tables occupying large space due to large initial extents storage parameterYou might have modified the initial extent size before to your load by pre-created tables ,which might helped out with current situation prior to this as you might be well known with your current database. Does the segement using Autoallocate or Uniform. What is the block size of DB.
- Pavan Kumar N -
Query to find numbers with dashes
Help. I want to write a query that will return all the numbers in my table that have dashes (-) in positions 5, 8 and 12. I tried using the INSTR function, with the positions, but do not get the desired result.
All suggestions are welcome!SQL> create table y as select '1234-67-901-34' y from dual;
Table created.
SQL> select to_number(x) from (select replace(y,'-') x from y where substr(y,5,1)='-' and substr(y,8,1)='-' and substr(y,12,1)='-')
TO_NUMBER(X)
12346790134 -
Query to find SQL with changed plans
I am trying to find out which SQL statements have changed plans since they were first executed.
I'm trying to run this on all databases from 9i upwards and I am assuming that I have no licensed access to the AWR. However, Statspack is installed on all databases. (So querying things like STATS$SQL_PLAN is fine).
I am having difficulty understanding what HASH_VALUE, OLD_HASH_VALUE and PLAN_HASH_VALUE are, and how they can be used to help answer the problem. I am also trying not to use SQL_ID, since that column isn't there in 9i (I think), and I'd like something that is generically usable from 9i to 11g, if at all possible.
Any hints, please.
Edited by: Catfive Lander on May 14, 2012 12:01 AMHi Sakshi,
Try out this query if it can help you !
SELECT a.user_name, a.description, c.responsibility_name, c.creation_date as ASSIGNED_DATE>FROM apps.fnd_user a,
>apps.fnd_user_resp_groups b,
>apps.fnd_responsibility_vl c
>WHERE a.user_id = b.user_id
>AND b.responsibility_id = c.responsibility_id
>AND a.creation_date < = '01-JUN-07'
ORDER BY a.user_name;Thanks,
Anchorage :) -
SCCM 2012 Query to find units with IPv6 Enabled?
We've found a need to locate computers that may have IPv6 enabled for audit purposes, and then we'll disable them at a later date.
Has anyone been able to create a successful query in SCCM 2012 to get that information?
I found this but it spit back the IPv4 info for all the units in our device collection, plus it's for SCCM 2007. http://www.myitforum.com/forums/Query-for-systems-with-IPv6-enabled-m227020.aspx
Appreciate any input, thanks!
This topic first appeared in the Spiceworks CommunityIf you're using % in the value field the operator must be "Like" . In your case, the query should look like
select SMS_R_USER.ResourceID,SMS_R_USER.ResourceType,SMS_R_USER.Name,SMS_R_USER.UniqueUserName,SMS_R_USER.WindowsNTDomain from SMS_R_User where SMS_R_User.UserPrincipalName Like
"TQA%" order by SMS_R_User.UserPrincipalName
Kindly mark as answer/Vote as helpful if a reply from anybody helped you in this forum. Delphin -
SQL Query - To Find Users with end dated responsibilities
Oracle Apps ver: 11.5.10.2
Oracle DB - 9i
How can i list users and the access assigned to them for a specific division irrespective of the responsibility being end dated at responsibility levelHi Sakshi,
Try out this query if it can help you !
SELECT a.user_name, a.description, c.responsibility_name, c.creation_date as ASSIGNED_DATE>FROM apps.fnd_user a,
>apps.fnd_user_resp_groups b,
>apps.fnd_responsibility_vl c
>WHERE a.user_id = b.user_id
>AND b.responsibility_id = c.responsibility_id
>AND a.creation_date < = '01-JUN-07'
ORDER BY a.user_name;Thanks,
Anchorage :) -
Query to get list of customers with partial shipments
I have a scenario where I need to find customers with open orders. (Orders and Shipments have 1-to-many relationship ):
Orders = (order_id PK, cust_id FK, prod_id FK, order_quantity, order_date)
Shipments = (shipment_id, order_id FK, shipment_quantity, shipment_date)
Open orders have 2 scenarios:
1) orders without shipment records
2) partial shipments:
e.g. 1 order record with quantity 10.
2 records in shipments table, 1 row with quantity 3, and the 2nd row with quantity 4; total shipped quantity is 7, which is less than order quantity of 10
How can I get this?ZaafranAhmed wrote:
I have a scenario where I need to find customers with open orders. (Orders and Shipments have 1-to-many relationship ):
Orders = (order_id PK, cust_id FK, prod_id FK, order_quantity, order_date)
Shipments = (shipment_id, order_id FK, shipment_quantity, shipment_date)
Open orders have 2 scenarios:
1) orders without shipment records
2) partial shipments:
e.g. 1 order record with quantity 10.
2 records in shipments table, 1 row with quantity 3, and the 2nd row with quantity 4; total shipped quantity is 7, which is less than order quantity of 10
How can I get this?
SELECT order_id
FROM orders
WHERE order_quantity > (SELECT SUM(shipment_quantity)
FROM shipments
WHERE orders.order_id = shipments.order_id); -
Query to find out controls displayed as in UI for an applet,along with view
Hi,
I am looking for a query to find out list of all the controls as displayed in UI applet along with applet's view.
Please note that in the query only mapped controls (those displayed in UI ) should come up.
Regards,
KunalHi,
If the EUL is an apps mode (EBS) EUL then the eu_username column is the apps user id or apps resp id. If you want to show only the responsibilities and convert those ids to names then you need to use the EUL5_GET_APPS_USERRESP function like this:
select ba_name, ba_developer_key, EUL5_GET_APPS_USERRESP(eu.eu_username, 'R') responsibility_name
from eul5_bas ba
, eul5_access_privs ap
, eul5_eul_users eu
where ba.ba_id = ap.gba_ba_id
and ap.ap_type = 'GBA'
and ap.ap_eu_id = eu.eu_id
and eu.eu_role_flag=1
order by 1,2,3Rod West -
Query to find the latest record with respect to the current status
Dear gurus
I have the following data in a table
Customernum
bkcode
reqtdate
Prevstat
currstat
The data will be like this
CustomerNum bkcode reqdate prevstat currstat
5900 1 03-Aug-12 0 1
5900 1 06-Aug-12 1 0
5900 5 22-Jun-12 0 1
If a customer has an issue to solved, a record is added with bkcode , register date and currstat will be 1
If the issue is resolved for the bookingcode,a new record is added, the currentstatus will become 0. and prev stat will show 1. Row no 1 and 2 reflects this case
If this table is queried for finding the unresolved issues. the output should be only the Last row of the above example. since issue with bookingcode 1 has been resolved
I have trying hard to get this thing confused what to use Lead or Max
Kindly guide meHi,
one way here:
WITH mytable(CustomerNum, bkcode, reqdate, prevstat, currstat)
AS
SELECT 5900, 1, TO_DATE('03-Aug-12', 'DD-Mon-YY'), 0, 1 FROM DUAL UNION ALL
SELECT 5900, 1, TO_DATE('06-Aug-12', 'DD-Mon-YY'), 1, 0 FROM DUAL UNION ALL
SELECT 5900, 5, TO_DATE('22-Jun-12', 'DD-Mon-YY'), 0, 1 FROM DUAL
SELECT CustomerNum, bkcode, reqdate, prevstat, currstat
FROM (SELECT a.*
, ROW_NUMBER() OVER (PARTITION BY CustomerNum, bkcode
ORDER BY reqdate DESC) AS rn
FROM mytable a
WHERE rn=1
AND currstat=1;
CUSTOMERNUM BKCODE REQDATE PREVSTAT CURRSTAT
5900 5 22-JUN-12 0 1Regards.
Al
Edited by: Alberto Faenza on Dec 18, 2012 5:23 PM
Changed again!! Previous logic was wrong
Maybe you are looking for
-
Safari no longer loads bookmarks after Leopard installed
I've recently upgraded to Leopard but since the upgrade I can no longer get to my bookmarks in Safari. I suspected that the file containing the bookmark info may have become corrupt, but after importing the file into Firefox, the bookmarks work fine.
-
I have a late 2011 MacBook Pro 13" and bought a brand new iMac 27" last week. I tried to transfer data (musdic & photos) via Thunderbolt, but i did not run, my system always tries to transfer data via WLAN, but that would last more than 80 hours. I t
-
Project Conventions + CVS + ANT
Hi The "Project Conventions for Enterprise Applications Early Access 1" helped us solve some issues with the project layout. As most of the standard tools we use CVS for team synchronization. Now the problem that arises is, we have 10 common componen
-
DTS 6.1 discrete by x-fi extrememusic soundc
hi everyone i have recently take x-fi extrememusic sound card , i would like to know whether my sound card is able to play DTS 6. discrete mode or it uses the DTS 6. Matrix method for playing the DVD which are given the certification of DTS 6. Discre
-
I know you can play music over multiple speakers but is it possible to play video on an apple tv and the audio that goes with that video on an airport express at the same time? It would be nice to have some better sound then my tv speakers while wat