Sql query--price
Hi
I have two tables prod and price and i need a below output,plz help
prod table
NO NAME
1 bike
2 bullet
3 car
4 flight
price table
NO PRICE
1 100
2 200
300
600
output
NO NAME price
1 bike 100
2 bullet 200
3 car 300
4 flight 600
Hi,
Welcome to the forum!
Why do you want these results:
NO NAME PRICE
1 bike 100
2 bullet 200
3 car 300
4 flight 600rather than these:NO NAME PRICE
1 bike 100
2 bullet 200
3 car 600
4 flight 300or these
NO NAME PRICE
1 bike 100
2 bullet 200
3 car 600
4 flight 600? That is, what links 'car' to 300, and not to 600? Or would you be content with any of the results above?
That error message means what it says: you're using a scalar sub-query, which is supposed to return (at most) one value, but the sub-query is finding 2 rows. Whcih one do you want to use when that happens?
What results would you want of you added this row to your sample data?
INSERT INTO prod (no, name) VALUES (5, 'widget');? What results would you want with your original data ( without the row above), plus this row?
INSERT INTO price (no, price) VALUES (NULL, 700);Depending on your answers, you might want to use JOIN and GROUP BY rather than a scalar sub-query. (Actually, you may want to use a JOIN rather than a scalar sub-query anyway.)
Similar Messages
-
hi Experts,
while running SQL Query i am getting an error as
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator. for the query
select T1. Dscription,T1.docEntry,T1.Quantity,T1.Price ,
T2.LineText
from OQUT T0 INNER JOIN QUT1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN
QUT10 T2 ON T1.DocEntry = T2.DocEntry where T1.DocEntry='590'
group by T1. Dscription,T1.docEntry,T1.Quantity,T1.Price
,T2.LineText
how to resolve the issueDear Meghanath,
Please use the following query, Hope your purpose will serve.
select T1. Dscription,T1.docEntry,T1.Quantity,T1.Price ,
CAST(T2.LineText as nvarchar (MAX))[LineText]
from OQUT T0 INNER JOIN QUT1 T1 ON T0.DocEntry = T1.DocEntry LEFT OUTER JOIN
QUT10 T2 ON T1.DocEntry = T2.DocEntry --where T1.DocEntry='590'
group by T1. Dscription,T1.docEntry,T1.Quantity,T1.Price
,CAST(T2.LineText as nvarchar (MAX))
Regards,
Amit -
SQL Query Help - Is this possible or impossible????
Hi guys,
I need help with an SQL query that I'm trying to develop. It's very easy to explain but when trying to implement it, I'm struggling to achieve the results that I want.....
For example,
I have 2 tables
The first table is:
1) COMPANY create table company (manufacturer varchar2(25),
date_established date,
location varchar2(25) );My sample test date is:
insert into company values ('Ford', 1902, 'USA');
insert into company values ('BMW', 1910, 'Germany');
insert into company values ('Tata', 1922, 'India');The second table is:
2) MODELS create table models (manufacturer varchar(25),
model varchar2(25),
price number(10),
year date,
current_production_status varchar2(1) ) ;My sample test data is:
insert into models values ('Ford', 'Mondeo', 10000, 2010, 0);
insert into models values ('Ford', 'Galaxy', 12000, 2008, 0);
insert into models values ('Ford', 'Escort', 10000, 1992, 1);
insert into models values ('BMW', '318', 17500, 2010, 0);
insert into models values ('BMW', '535d', 32000, 2006, 0);
insert into models values ('BMW', 'Z4', 10000, 1992, 0);
insert into models values ('Tata', 'Safari', 4000, 1999, 0);
insert into models values ('Tata', 'Sumo', 5500, 1996, 1);
insert into models values ('Tata', 'Maruti', 3500, 1998, 0);And this is my query:
SELECT
com.manufacturer,
com.date_established,
com.location,
DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.model),
DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.price),
DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.year),
mod.current_production_status
FROM
company com,
models mod
WHERE
mod.manufacturer = com.manufacturer
and com.manufacturer IN ('Ford', 'BMW', 'Tata')
and mod.current_production_status IN (1,0)
ORDER BY
mod.current_production_status DESCWhat I want the query to output is this:
com.manufacturer com.date_established com.location mod.model mod.price mod.year mod.current_production_status
Ford 1902 USA Escort 10000 1992 1
BMW 1910 Germany - - - 0
Tata 1922 India Sumo 5500 1998 1If current_production_status is 1 it means this particular model has been discontinued
If current_production_status is 0 it means the manufacturer does not have any discontinued models and all are in procuction.
The rule is only one record per manufacturer is allowed to have a current_production_status of 1 (so only one model from the selection the manufactuer offers is allowed to be discontinued).
So the query should output the one row where current_production_status is 1 for each manufacturer.
If for a given manufacturer there are no discontinued models and all have a current_production_status of 0 then ouput a SINGLE row that only includes the data from the COMPANY table (as above). The rest of the columns from the MODELS table should be populated with a '-' (hyphen).
My query as it is above will output all the records where current status is 1 or 0 like this
com.manufacturer com.date_established com.location mod.model mod.price mod.year mod.current_production_status
Ford 1902 USA Escort 10000 1992 1
Tata 1922 India Sumo 5500 1998 1
Ford 1902 USA - - - 0
Ford 1902 USA - - - 0
BMW 1910 Germany - - - 0
BMW 1910 Germany - - - 0
BMW 1910 Germany - - - 0
Tata 1922 India - - - 0
Tata 1922 India - - - 0However this is not what I want.
Any ideas how I can achieve the result I need?
Thanks!
P.S. Database version is '10.2.0.1.0'Hi Vishnu,
Karthiks query helped...
But this is the problem I am facing...
SELECT
com.manufacturer,
com.date_established,
com.location,
DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.model),
DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.price),
DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.year),
mod.current_production_status
FROM
company com,
models mod
WHERE
mod.manufacturer = com.manufacturer
and com.manufacturer = 'Ford'
and mod.current_production_status IN (1,0)
ORDER BY
mod.current_production_status DESCThe value of:
and com.manufacturer = 'Ford'will be dependent on front end user input....
When I run the query above I get all the rows where current_production_status is either 1 or 0.
I only require the rows where current_production_status is 1.
So if I amend it to look like this:
and mod.current_production_status = 1This works....
BUT if a user now passes in more than one manufacturer EG:
and com.manufacturer IN ('Ford', 'BMW')The query will only return the one row for Ford where current_production_status is 1. However because BMW has no models where current_production_status is 1 (all 3 are 0), I still want this to be output - as one row....
So like this:
com.manufacturer com.date_established com.location mod.model mod.price mod.year mod.current_production_status
Ford 1902 USA Escort 10000 1992 1
BMW 1910 Germany - - - 0So (hopefully you understand), I want both cases to be catered for.....whether a user enters one manufacturer or more than one...
Thanks you so much!
This is really driving me insane :-( -
Using '(' and less than operator in an xsql page sql query
Dear All,
I tried to use left parenthesis '(' and less than operator in an sql query through an xsql page, it doesn't let to use them.
Do you know how to use those in an xsql page?
Thanks for your help.
MustafaFollowing is the xsql page that I tried to run:
<?xml version="1.0"?>
<xsql:query xmlns:xsql="urn:oracle-xsql" connection = "bib" rowset-element="bib" row-element="book">
(SELECT year,title,last,first,' ' as affiliation,publisher,price
FROM book,author
WHERE year=2001 and bookid=parentid
UNION
SELECT year,title,last,first,affiliation,publisher,price
FROM book,editor
WHERE year=2001 and bookid=parentid)
INTERSECT
(SELECT year,title,last,first,' ' as affiliation,publisher,price
FROM book,author
WHERE publisher='Publisher1' and bookid=parentid
UNION
SELECT year,title,last,first,affiliation,publisher,price
FROM book,editor
WHERE publisher='Publisher1' and bookid=parentid)
</xsql:query>
This is the error message generated after running:
<ERROR>java.sql.SQLException: ORA-01009: missing mandatory parameter</ERROR>
When I remove the parentheses it works but this results in a different result set.
Can anybody tell me the reason?
Thanks,
Mustafa
null -
SQL query performance issues.
Hi All,
I worked on the query a month ago and the fix worked for me in test intance but failed in production. Following is the URL for the previous thread.
SQL query performance issues.
Following is the tkprof file.
CURSOR_ID:76 LENGTH:2383 ADDRESS:f6b40ab0 HASH_VALUE:2459471753 OPTIMIZER_GOAL:ALL_ROWS USER_ID:443 (APPS)
insert into cos_temp(
TRX_DATE, DEPT, PRODUCT_LINE, PART_NUMBER,
CUSTOMER_NUMBER, QUANTITY_SOLD, ORDER_NUMBER,
INVOICE_NUMBER, EXT_SALES, EXT_COS,
GROSS_PROFIT, ACCT_DATE,
SHIPMENT_TYPE,
FROM_ORGANIZATION_ID,
FROM_ORGANIZATION_CODE)
select a.trx_date,
g.segment5 dept,
g.segment4 prd,
m.segment1 part,
d.customer_number customer,
b.quantity_invoiced units,
-- substr(a.sales_order,1,6) order#,
substr(ltrim(b.interface_line_attribute1),1,10) order#,
a.trx_number invoice,
(b.quantity_invoiced * b.unit_selling_price) sales,
(b.quantity_invoiced * nvl(price.operand,0)) cos,
(b.quantity_invoiced * b.unit_selling_price) -
(b.quantity_invoiced * nvl(price.operand,0)) profit,
to_char(to_date('2010/02/28 00:00:00','yyyy/mm/dd HH24:MI:SS'),'DD-MON-RR') acct_date,
'DRP',
l.ship_from_org_id,
p.organization_code
from ra_customers d,
gl_code_combinations g,
mtl_system_items m,
ra_cust_trx_line_gl_dist c,
ra_customer_trx_lines b,
ra_customer_trx_all a,
apps.oe_order_lines l,
apps.HR_ORGANIZATION_INFORMATION i,
apps.MTL_INTERCOMPANY_PARAMETERS inter,
apps.HZ_CUST_SITE_USES_ALL site,
apps.qp_list_lines_v price,
apps.mtl_parameters p
where a.trx_date between to_date('2010/02/01 00:00:00','yyyy/mm/dd HH24:MI:SS')
and to_date('2010/02/28 00:00:00','yyyy/mm/dd HH24:MI:SS')+0.9999
and a.batch_source_id = 1001 -- Sales order shipped other OU
and a.complete_flag = 'Y'
and a.customer_trx_id = b.customer_trx_id
and b.customer_trx_line_id = c.customer_trx_line_id
and a.sold_to_customer_id = d.customer_id
and b.inventory_item_id = m.inventory_item_id
and m.organization_id
= decode(substr(g.segment4,1,2),'01',5004,'03',5004,
'02',5003,'00',5001,5002)
and nvl(m.item_type,'0') <> '111'
and c.code_combination_id = g.code_combination_id+0
and l.line_id = b.interface_line_attribute6
and i.organization_id = l.ship_from_org_id
and p.organization_id = l.ship_from_org_id
and i.org_information3 <> '5108'
and inter.ship_organization_id = i.org_information3
and inter.sell_organization_id = '5108'
and inter.customer_site_id = site.site_use_id
and site.price_list_id = price.list_header_id
and product_attr_value = to_char(m.inventory_item_id)
call count cpu elapsed disk query current rows misses
Parse 1 0.47 0.56 11 197 0 0 1
Execute 1 3733.40 3739.40 34893 519962154 11 188 0
total 2 3733.87 3739.97 34904 519962351 11 188 1
| Rows Row Source Operation
| ------------ ---------------------------------------------------
| 188 HASH JOIN (cr=519962149 pr=34889 pw=0 time=2607.35)
| 741 .TABLE ACCESS BY INDEX ROWID QP_PRICING_ATTRIBUTES (cr=519939426 pr=34889 pw=0 time=2457.32)
| 254644500 ..NESTED LOOPS (cr=519939265 pr=34777 pw=0 time=3819.67)
| 254643758 ...NESTED LOOPS (cr=8921833 pr=29939 pw=0 time=1274.41)
| 741 ....NESTED LOOPS (cr=50042 pr=7230 pw=0 time=11.37)
| 741 .....NESTED LOOPS (cr=48558 pr=7229 pw=0 time=11.35)
| 741 ......NESTED LOOPS (cr=47815 pr=7223 pw=0 time=11.32)
| 3237 .......NESTED LOOPS (cr=41339 pr=7223 pw=0 time=12.42)
| 3237 ........NESTED LOOPS (cr=38100 pr=7223 pw=0 time=12.39)
| 3237 .........NESTED LOOPS (cr=28296 pr=7139 pw=0 time=12.29)
| 1027 ..........NESTED LOOPS (cr=17656 pr=4471 pw=0 time=3.81)
| 1027 ...........NESTED LOOPS (cr=13537 pr=4404 pw=0 time=3.30)
| 486 ............NESTED LOOPS (cr=10873 pr=4240 pw=0 time=0.04)
| 486 .............NESTED LOOPS (cr=10385 pr=4240 pw=0 time=0.03)
| 486 ..............TABLE ACCESS BY INDEX ROWID RA_CUSTOMER_TRX_ALL (cr=9411 pr=4240 pw=0 time=0.02)
| 75253 ...............INDEX RANGE SCAN RA_CUSTOMER_TRX_N5 (cr=403 pr=285 pw=0 time=0.38)
| 486 ..............TABLE ACCESS BY INDEX ROWID HZ_CUST_ACCOUNTS (cr=974 pr=0 pw=0 time=0.01)
| 486 ...............INDEX UNIQUE SCAN HZ_CUST_ACCOUNTS_U1 (cr=488 pr=0 pw=0 time=0.01)
| 486 .............INDEX UNIQUE SCAN HZ_PARTIES_U1 (cr=488 pr=0 pw=0 time=0.01)
| 1027 ............TABLE ACCESS BY INDEX ROWID RA_CUSTOMER_TRX_LINES_ALL (cr=2664 pr=164 pw=0 time=1.95)
| 2063 .............INDEX RANGE SCAN RA_CUSTOMER_TRX_LINES_N2 (cr=1474 pr=28 pw=0 time=0.22)
| 1027 ...........TABLE ACCESS BY INDEX ROWID RA_CUST_TRX_LINE_GL_DIST_ALL (cr=4119 pr=67 pw=0 time=0.54)
| 1027 ............INDEX RANGE SCAN RA_CUST_TRX_LINE_GL_DIST_N1 (cr=3092 pr=31 pw=0 time=0.20)
| 3237 ..........TABLE ACCESS BY INDEX ROWID MTL_SYSTEM_ITEMS_B (cr=10640 pr=2668 pw=0 time=15.35)
| 3237 ...........INDEX RANGE SCAN MTL_SYSTEM_ITEMS_B_U1 (cr=2062 pr=40 pw=0 time=0.33)
| 3237 .........TABLE ACCESS BY INDEX ROWID OE_ORDER_LINES_ALL (cr=9804 pr=84 pw=0 time=0.77)
| 3237 ..........INDEX UNIQUE SCAN OE_ORDER_LINES_U1 (cr=6476 pr=47 pw=0 time=0.43)
| 3237 ........TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=3239 pr=0 pw=0 time=0.04)
| 3237 .........INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=2 pr=0 pw=0 time=0.01)
| 741 .......TABLE ACCESS BY INDEX ROWID HR_ORGANIZATION_INFORMATION (cr=6476 pr=0 pw=0 time=0.10)
| 6474 ........INDEX RANGE SCAN HR_ORGANIZATION_INFORMATIO_FK2 (cr=3239 pr=0 pw=0 time=0.03)Please help.
Regards
Ashish| 254644500 ..NESTED LOOPS (cr=519939265 pr=34777 pw=0 time=3819.67)
| 254643758 ...NESTED LOOPS (cr=8921833 pr=29939 pw=0 time=1274.41)There is no way the optimizer should choose to process that many rows using nested loops.
Either the statistics are not up to date, the data values are skewed or you have some optimizer parameter set to none default to force index access.
Please post explain plan and optimizer* parameter settings. -
Oracle to MS SQL Migration Price Prediction
We want to calculate approximate man-month for migrating from Oracle 11g to MS SQL 2012. I have read the steps of migration. Are there any white papers about migration issues, difficulties. We are also using Hibernate in ORM layer. How can we predict migration
cost according to table size or relation count, HQL or native SQL query number or other criteria?Hi ozgurba,
According to your description, you could download and use the free tool
Microsoft SQL Server Migration Assistant v6.0 for Oracle(SSMA) to migrate Oracle database to SQL Server 2012. About migration issues using SSMA, please pay attention to the points below. For more information about migration issues, please download and check
this
white paper.
1.The account that is used to connect to the Oracle database must have at least CONNECT permissions. This enables SSMA to obtain metadata from schemas owned by the connecting user. To obtain metadata for objects in other schemas and then convert objects
in those schemas, the account must have the following permissions: CREATE ANY PROCEDURE, EXECUTE ANY PROCEDURE, SELECT ANY TABLE, SELECT ANY SEQUENCE, CREATE ANY TYPE, CREATE ANY TRIGGER, SELECT ANY DICTIONARY.
2.The account that is used to connect to SQL Server requires different permissions depending on the actions that the account performs as the following:
To convert Oracle objects to Transact-SQL syntax, to update metadata from SQL Server, or to save converted syntax to scripts, the account must have permission to log on to the instance of SQL Server.
To load database objects into SQL Server, the account must be a member of the sysadmin server role. This is required to install CLR assemblies.
To migrate data to SQL Server, the account must be a member of the sysadmin server role. This is required to run the SQL Server Agent data migration packages.
To run the code that is generated by SSMA, the account must have Execute permissions for all user-defined functions in the ssma_oracle schema of the target database. These functions provide equivalent functionality of Oracle system functions, and are used
by converted objects.
If the account that is used to connect to SQL Server is to perform all migration tasks, the account must be a member of the sysadmin server role.
If the engine being used is Server Side Data Migration Engine, then, before you can migrate data, you must install the SSMA for Oracle Extension Pack and the Oracle providers on the computer that is running SSMA. The SQL Server Agent service must also be
running. And when SQL Express edition is used as the target database, only client side data migration is allowed and server side data migration is not supported.
3.Not all Oracle database objects have direct equivalents in SQL Server. In many cases, SSMA creates additional objects to provide the proper emulation. For example, an Oracle view could be converted to an SQL Server view. But the only exception is the materialized
view, which becomes an ordinary table.
4.Oracle DML triggers are converted to SQL Server triggers, but because the trigger functionality is different, the number of triggers and their types can be changed. Most common Oracle trigger is a row-level trigger (FOR EACH ROW). SQL Server supports only
statement-level triggers. In a row-level trigger, Oracle uses an :OLD alias to refer to column values that existed before the statement executes. SQL Server uses two pseudotables, inserted and deleted. If you are converting tables with UPDATE triggers, we
recommend setting the Generate ROWID column option to Yes or Add ROWID column for tables with triggers in the SSMA project settings. To emulate row-level triggers, SSMA processes each row in a cursor loop.
5.Some Oracle object categories, such as packages, do not have direct SQL Server equivalents. SSMA converts each packaged procedure or function into separate target subroutines and applies rules for stand-alone procedures or functions.
6.Unlike Oracle, Microsoft SQL Server 2012 supports neither records nor collections. When you migrate from Oracle to SQL Server 2012, therefore, you must apply substantial transformations to the PL/SQL code.
7.SQL Server 2012 does not support autonomous transactions. The only way to isolate a Transact-SQL block from a transaction context is to open a new connection. To convert a procedure, function, or trigger with an AUTONOMOUS_TRANSACTION flag, you split it
into two objects. The first object is a stored procedure containing the body of the converted object. The second object is a wrapper that opens a new connection where it invokes the first object.
In addition, regarding migration price prediction, please ask for the help from relevant department of your company, since this forum is related to the technical support for SQL Server.
Regards,
Michelle Li -
Hi All
This is mu use case
1. I have a table called Trades which stores Trades from different clients
2. In Trade Table I have a field called 'TRADE_FEE_REF' which store all the fees for a trade as a reference
3. In table 'TRADE_FEE_DETAILS' it stores the fees related to a perticular trade
4. Trades and TRADE_FEE_DETAILS tables have a foriegn key.
5. Now I want to display the following result for user.
I want a single row for Trades which includes Fee details as columns in that selection
ex: This is a Row from Trade table
Date, quantity, Price, Free_ref_no
1/1/2011, 2000, 12.45 , 1
This is the records from TRADE_FEE_DETAILS for the perticular trade above
Fee_Ref, Fee_type,Fee_amount
1 ,BR, 200
1 ,ST,300
1 ,STT,100
now I want to display the result as follow
Date, quantity, Price, BR,ST,STT
1/1/2011, 2000, 12.45,200,300,100
How do I retrieve this result from sql query
Thnks
PadmaYou can use PIVOT function to convert rows to columns
with trade as
select to_DATE('1-JAN-2011','DD-MON-YYYY') col_date, 2000 quantity, 12.45 Price, 1 Free_ref_no from dual
trade_fee_details as
select 1 Fee_Ref, 'BR' Fee_type, 200 Fee_amount from dual union all
select 1, 'ST', 300 from dual union all
select 1, 'STT', 100 from dual
SELECT
td.col_date,
td.quantity,
td.price,
tf.BR,
tf.ST,
tf.STT
FROM
trade td,
SELECT
FROM
SELECT
FROM
trade_fee_details
PIVOT (SUM(Fee_amount) FOR Fee_type IN ( 'BR' AS BR,'ST' AS ST,'STT' AS STT ))
) tf
WHERE
td.Free_ref_no = tf.fee_ref;
COL_DATE QUANTITY PRICE BR ST STT
01-JAN-11 00:00:00 2000 12.45 200 300 100 -
i am trying to write sql query for a single recordset.
I have an items table with all the standard item info and an item_colorID.
i have a color_lookup table with 2 columns, item_colorID and color_ID
i have a colors table with 2 columns, color_ID and color
i want to join the tables and filter it so that a repeat region shows dynamic data of item name, description, thumb, price
and also a list/menu dynamically populated by color
filtered so that each item shows in the list/menu only the colors that the item has available.
i have tried different variations of this sql
SELECT * FROM items INNER JOIN color_lookup ON color_lookup.item_colorID = items.item_colorID INNER JOIN colors ON colors.color_ID = color_lookup.color_ID WHERE items.itemCatID = 3 ORDER BY items.itemName
but the list/menu shows every color choice multiplied by the number of items in that color
ie White will show 80+ times.
thanks for your help,
jim balthropbregent,
thanks for your help.
I am building a shopping cart and i have a recordset to list the items and a repeat region for that recordset
i have a second recordset for the colors joined to the item_colorID nested inside the repeat region.
the shopping cart software has a 'lookup from recordset' choice for the add to cart servior behavior
and then i bind to the columns on the cart page.
it produces this code
if (isset($totalRows_rs_itemscat3) && $totalRows_rs_itemscat3 > 0) {
$row_rs_itemscat3 = WAEC_findRecordMySQL($rs_itemscat3, "item_ID", $ATC_itemID);
if ($row_rs_itemscat3) {
$ATC_itemName = "".$row_rs_itemscat3['itemName'] ."";// column binding
$ATC_itemDescription = "".$row_rs_itemscat3['itemShortDesc'] ."";// column binding
$ATC_itemWeight = floatval("".$row_rs_itemscat3['itemWeight'] ."");// column binding
$ATC_itemQuantity = "".$_POST["Farrington_1_Quantity_Add"] ."";// column binding
$ATC_itemPrice = floatval("".$row_rs_itemscat3['itemPrice'] ."");// column binding
$ATC_itemThumbnail = "".$row_rs_itemscat3['itemThumb'] ."";// column binding
$ATC_itemcolorchoice = "".$row_rs_colors['color'] ."";// column binding
mysql_data_seek($rs_itemscat3, 0);
$row_rs_itemscat3 = mysql_fetch_assoc($rs_itemscat3);
the column binding for the colors is from a different recordset and when redirecting to the cart page the color info will not show.
So my thinking is if i could get the color list/menu to populate from the same recordset as the item listing, it would solve my add to cart server behavior.
Is it possible to do this with only one recordset?
the products page and the cart page can be seen
http://www.farrington-enterprises.com/rain-gutters.php
add an item to the cart with any color choice and the color info does not carry to the cart. -
Obtain rows from a complex sql query
Hi to all, please somebody who can help me, my scenario is as next:
One table like next
Reservation (table)
Boat (string)
reservation (date)
class (string)
room1_cod (int)
room1 (int)
room2_cod (int)
room2 (int)
room3_cod (int)
room3 (int)
In room(x)_cod , I am saving a client code, in the room(x) , I am saving the price of the room for that client.
example:
LUSITANIA, 2014-3-1, MEDIUM, 0, 0, 145, 345, 0, 0 = client 145 ocupied room 2 paying $345
LUSITANIA, 2014-2-1, MEDIUM, 145, 345, 0, 0, 0, 0 = client 145 ocupied room 1 paying $345
LUSITANIA, 2014-1-1, MEDIUM, 0, 0, 0, 0, 145, 345 = client 145 ocupied room 3 paying $345
how would like to make an sql query for filter :
(Boat, reservation, class... with a reservation start date and finish date and with an specific "client code" find and filter this code into room1_cod , room2_cod and room3_cod .... and maybe do a temporarly table with rows containing (Boat, Reservation,
Class, "client_code" , "client_pay" )
Resulting LIKE:
LUSITANIA, 2014-3-1, MEDIUM, 145, 345
LUSITANIA, 2014-2-1, MEDIUM, 145, 345
LUSITANIA, 2014-1-1, MEDIUM, 145, 345
Please I need your guidance. TKSPlease take a look
SELECT Boat, reservation, class,
case
when room1_cod>0 then 1
when room2_cod>0 then 2
when room3_cod>0 then 3
end as Room,
case
when room1_cod>0 then room1_cod
when room2_cod>0 then room2_cod
when room3_cod>0 then room3_cod
end as client_code,
case
when room1>0 then room1
when room2>0 then room2
when room3>0 then room3
end as client_pay
from
SELECT 'LUSITANIA' AS Boat, CONVERT(DATE,'2014-3-1',121) AS reservation, 'MEDIUM' AS class, 0 AS room1_cod, 0 AS room1, 145 AS room2_cod, 345 AS room2, 0 AS room3_cod, 0 AS room3 ---//client 145 ocupied room 2 paying $345
union all
SELECT 'LUSITANIA' AS Boat, CONVERT(DATE,'2014-2-1',121) AS reservation, 'MEDIUM' AS class, 145 AS room1_cod, 345 AS room1, 0 AS room2_cod, 0 AS room2, 0 AS room3_cod, 0 AS room3 --//= client 145 ocupied room 1 paying $345
union all
SELECT 'LUSITANIA' AS Boat, CONVERT(DATE,'2014-1-1',121) AS reservation, 'MEDIUM' AS class, 0 AS room1_cod, 0 AS room1, 0 AS room2_cod, 0 AS room2, 145 AS room3_cod, 345 AS room3 --//= client 145 ocupied room 3 paying $345
) as Reservation
----Better table design would eliminate multiple columns for each room/client code/rate like the following
SELECT
Boat, reservation, class,
Room,
room_cod as client_code,
room_rate as client_pay
from
SELECT 'LUSITANIA' AS Boat, CONVERT(DATE,'2014-3-1',121) AS reservation, 'MEDIUM' AS class, 2 AS room, 145 AS room_cod, 345 AS room_rate ---//client 145 ocupied room 2 paying $345
union all
SELECT 'LUSITANIA' AS Boat, CONVERT(DATE,'2014-2-1',121) AS reservation, 'MEDIUM' AS class, 1 AS room, 145 AS room_cod, 345 AS room_rate --//= client 145 ocupied room 1 paying $345
union all
SELECT 'LUSITANIA' AS Boat, CONVERT(DATE,'2014-1-1',121) AS reservation, 'MEDIUM' AS class, 3 AS room, 145 AS room_cod, 345 AS room_rate --//= client 145 ocupied room 3 paying $345
) as Reservation
thanks for you effort, best regards -
How to modify a SQL query?
Hi all,
I am using Crystal Reports version 10. I have a number of reports that have been written by a software vendor wherby the name of the database they were connected to when the report was written is coded into the FROM command of the reports SQL query, eg "GCUK_2" in the of the SQL snippet below.
SELECT "Clients"."NAME", "Quotes"."QUOTE_ID", "Quote_Items"."UPRICE", "Quote_Items"."QTY", "Quote_Items"."UOM", "Quote_Items"."QUSAGE_ID", "Report_Control"."QUSAGEID", "Quote_Items"."STANDARD", "Quote_Items"."SECT_FLAG", "Quote_Items"."DISPORDER", "Quotes"."DESCRIPT", "Report_Control"."SECT_NAME", "Quote_Items"."CNT", "Category_and_Type"."TYPEDESC", "Quote_Items"."DESCRIPT", "Report_Control"."DISP_SORT"
FROM ((("GCUK_2"."schedwin"."QTE_CTRL" "Report_Control" INNER JOIN "GCUK_2"."schedwin"."QUSAGE" "Quote_Items" ON "Report_Control"."QUSAGEID"="Quote_Items"."QUSAGE_ID") LEFT OUTER JOIN "GCUK_2"."schedwin"."QUOTES" "Quotes" ON
I have tried setting the Datasource Location, but it doesn't change the query at all. I have read on another forum that you can generate another SQL query using the Database Expert, Current Connections, then right click the Add Command for the database you want to create a SQL command. Is this the only way to update the database names in the query?
Thanks,
Scott.Hi Sourashree,
Thanks for that. All the reports were created by the vendor using tables as opposed to the command object. I would have thought that changing the datasource would automatically cause Crystal to rewrite the SQL query syntax, but this doesn't appear to be the case.
Yes, I've noticed that modifying the record selection will change the sql query. The only way I can see to change the database name in the query is to change to the desired databsource and then remove and re-insert the tables, which will then update the query with the correct name. However, this seems to be a convoluted way of changing the db name in the query. -
Discoverer Report showing Null VS Show SQL query showing results !!!
I created a simple Cross Tab Discoverer report from a custom SQL which has a calculation for balances. The output is giving all null values even though there are balances. The output doesn't seem right. So I copied the query from Tools-->Show SQL and ran the query in the TOAD where I'm showing balances for the report. I don't understand why it is not showing in the discoverer. Please help.
Thanks
Edited by: PA1B on Jan 27, 2010 11:40 AMSorry for late reply.
Below is the Show SQL query. I don't think the query is application dependent. C_1 is my calculation.
SELECT o279709.SEGMENT3 as E279727,
o279709.SEGMENT4 as E279728,
CASE WHEN o279709.CURRENCY_CODE = 'USD' AND o279709.TRANSLATED_FLAG <> 'Y' THEN SUM(o279709.ENDING_BAL) ELSE 0 END as C_1,
GROUPING_ID(o279709.CURRENCY_CODE,o279709.SEGMENT3,o279709.SEGMENT4,o279709.TRANSLATED_FLAG) as GID
FROM ( --Foriegn Entity USD Balances
SELECT B.SEGMENT1,
B.SEGMENT2,
B.SEGMENT3,
(select distinct substr(cat.COMPILED_VALUE_ATTRIBUTES,5,1) from apps.fnd_flex_values cat
where FLEX_VALUE_SET_ID = (select bat.FLEX_VALUE_SET_ID from apps.fnd_id_flex_structures_vl aat, apps.fnd_id_flex_segments_vl bat
where bat.id_flex_code = 'GL#' and
bat.id_flex_code = aat.id_flex_code and
aat.APPLICATION_ID = bat.APPLICATION_ID and
aat.APPLICATION_ID = 101 and
bat.SEGMENT_NAME = 'Prime Account' and
aat.id_flex_num = bat.id_flex_num
and bat.id_flex_num in (select distinct chart_of_accounts_id from apps.gl_code_combinations gat
where gat.code_combination_id = A.code_combination_id))
and cat.flex_value = b.segment3) ACCT_TYPE ,
B.SEGMENT4,
B.SEGMENT5,
B.SEGMENT6,
B.SEGMENT7,
B.SEGMENT8,
B.SEGMENT9,
B.SEGMENT10,
B.SEGMENT11,
B.SEGMENT12,
B.SEGMENT13,
C.NAME,
A.SET_OF_BOOKS_ID,
A.CURRENCY_CODE,A.TRANSLATED_FLAG,
SUM(NVL(A.BEGIN_BALANCE_DR,0) - NVL(A.BEGIN_BALANCE_CR,0)) BEG_BAL,
SUM(NVL(A.PERIOD_NET_DR,0)) DEBITS,
SUM( NVL(A.PERIOD_NET_CR,0)) CREDITS ,
A.PERIOD_NAME,
SUM(NVL(A.BEGIN_BALANCE_DR,0) - NVL(A.BEGIN_BALANCE_CR,0))+ SUM(NVL(A.PERIOD_NET_DR,0) - NVL(A.PERIOD_NET_CR,0)) ENDING_BAL
FROM APPS.GL_BALANCES A ,
APPS.GL_CODE_COMBINATIONS B,
APPS.GL_SETS_OF_BOOKS C
WHERE A.CODE_COMBINATION_ID = B.CODE_COMBINATION_ID
--AND A.PERIOD_NAME = 'SEP-09'
AND C.SET_OF_BOOKS_ID = A.SET_OF_BOOKS_ID
--AND A.TRANSLATED_FLAG <> 'Y'
--AND B.SEGMENT1 = '83101'
--AND B.SEGMENT3 = '14602'
--AND A.SET_OF_BOOKS_ID = 77
--AND A.CURRENCY_CODE = 'USD'
GROUP BY A.CODE_COMBINATION_ID,
B.SEGMENT1,
B.SEGMENT2,
B.SEGMENT3,
B.SEGMENT4,
B.SEGMENT5,
B.SEGMENT6,
B.SEGMENT7,
B.SEGMENT8,
B.SEGMENT9,
B.SEGMENT10,
B.SEGMENT11,
B.SEGMENT12,
B.SEGMENT13,
A.CURRENCY_CODE,
A.TRANSLATED_FLAG,
C.NAME,A.PERIOD_NAME,
A.SET_OF_BOOKS_ID
) o279709
WHERE (o279709.PERIOD_NAME = 'DEC-09')
AND (o279709.SET_OF_BOOKS_ID <> 72)
AND (o279709.SEGMENT12 = '000')
AND (o279709.SEGMENT3 IN ('10101','10301','10502','12001'))
AND (o279709.SEGMENT1 IN ('82901','82902','82903','83001','83003','83201'))
GROUP BY GROUPING SETS(( o279709.CURRENCY_CODE,o279709.SEGMENT3,o279709.SEGMENT4,o279709.TRANSLATED_FLAG ),( o279709.SEGMENT3,o279709.SEGMENT4 ),( o279709.SEGMENT3 ))
HAVING (GROUP_ID()=0)
ORDER BY GID DESC;
Thanks,
PA1
Edited by: PA1B on Jan 29, 2010 12:50 PM -
Error while executing a sql query for select
HI All,
ORA-01652: unable to extend temp segment by 128 in tablespace PSTEMP i'm getting this error while i'm executing the sql query for selecting the data.I am having 44GB of temp space, while executing the below query my temp space is getting full, Expert please let us know how the issue can be resolved..
1. I dont want to increase the temp space
2. I need to tune the query, please provide your recomendations.
insert /*+APPEND*/ into CST_DSA.HIERARCHY_MISMATCHES
(REPORT_NUM,REPORT_TYPE,REPORT_DESC,GAP,CARRIED_ITEMS,CARRIED_ITEM_TYPE,NO_OF_ROUTE_OF_CARRIED_ITEM,CARRIED_ITEM_ROUTE_NO,CARRIER_ITEMS,CARRIER_ITEM_TYPE,CARRIED_ITEM_PROTECTION_TYPE,SOURCE_SYSTEM)
select
REPORTNUMBER,REPORTTYPE,REPORTDESCRIPTION ,NULL,
carried_items,carried_item_type,no_of_route_of_carried_item,carried_item_route_no,carrier_items,
carrier_item_type,carried_item_protection_type,'PACS'
from
(select distinct
c.REPORTNUMBER,c.REPORTTYPE,c.REPORTDESCRIPTION ,NULL,
a.carried_items,a.carried_item_type,a.no_of_route_of_carried_item,a.carried_item_route_no,a.carrier_items,
a.carrier_item_type,a.carried_item_protection_type,'PACS'
from CST_ASIR.HIERARCHY_asir a,CST_DSA.M_PB_CIRCUIT_ROUTING b ,CST_DSA.REPORT_METADATA c
where a.carrier_item_type in('Connection') and a.carried_item_type in('Service')
AND a.carrier_items=b.mux
and c.REPORTNUMBER=(case
when a.carrier_item_type in ('ServicePackage','Service','Connection') then 10
else 20
end)
and a.carrier_items not in (select carried_items from CST_ASIR.HIERARCHY_asir where carried_item_type in('Connection') ))A
where not exists
(select *
from CST_DSA.HIERARCHY_MISMATCHES B where
A.REPORTNUMBER=B.REPORT_NUM and
A.REPORTTYPE=B.REPORT_TYPE and
A.REPORTDESCRIPTION=B.REPORT_DESC and
A.CARRIED_ITEMS=B.CARRIED_ITEMS and
A.CARRIED_ITEM_TYPE=B.CARRIED_ITEM_TYPE and
A.NO_OF_ROUTE_OF_CARRIED_ITEM=B.NO_OF_ROUTE_OF_CARRIED_ITEM and
A.CARRIED_ITEM_ROUTE_NO=B.CARRIED_ITEM_ROUTE_NO and
A.CARRIER_ITEMS=B.CARRIER_ITEMS and
A.CARRIER_ITEM_TYPE=B.CARRIER_ITEM_TYPE and
A.CARRIED_ITEM_PROTECTION_TYPE=B.CARRIED_ITEM_PROTECTION_TYPE
AND B.SOURCE_SYSTEM='PACS'
Explain Plan
==========
Plan
INSERT STATEMENT ALL_ROWSCost: 129 Bytes: 1,103 Cardinality: 1
20 LOAD AS SELECT CST_DSA.HIERARCHY_MISMATCHES
19 PX COORDINATOR
18 PX SEND QC (RANDOM) PARALLEL_TO_SERIAL SYS.:TQ10002 :Q1002Cost: 129 Bytes: 1,103 Cardinality: 1
17 NESTED LOOPS PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 129 Bytes: 1,103 Cardinality: 1
15 HASH JOIN RIGHT ANTI NA PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 129 Bytes: 1,098 Cardinality: 1
4 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 63 Bytes: 359,283 Cardinality: 15,621
3 PX SEND BROADCAST PARALLEL_TO_PARALLEL SYS.:TQ10001 :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621
2 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621
1 MAT_VIEW ACCESS FULL MAT_VIEW PARALLEL_COMBINED_WITH_PARENT CST_ASIR.HIERARCHY :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621
14 NESTED LOOPS ANTI PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 65 Bytes: 40,256,600 Cardinality: 37,448
11 HASH JOIN PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 65 Bytes: 6,366,160 Cardinality: 37,448
8 BUFFER SORT PARALLEL_COMBINED_WITH_CHILD :Q1002
7 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 1 Bytes: 214 Cardinality: 2
6 PX SEND BROADCAST PARALLEL_FROM_SERIAL SYS.:TQ10000 Cost: 1 Bytes: 214 Cardinality: 2
5 INDEX FULL SCAN INDEX CST_DSA.IDX$$_06EF0005 Cost: 1 Bytes: 214 Cardinality: 2
10 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD :Q1002Cost: 63 Bytes: 2,359,224 Cardinality: 37,448
9 MAT_VIEW ACCESS FULL MAT_VIEW PARALLEL_COMBINED_WITH_PARENT CST_ASIR.HIERARCHY :Q1002Cost: 63 Bytes: 2,359,224 Cardinality: 37,448
13 TABLE ACCESS BY INDEX ROWID TABLE PARALLEL_COMBINED_WITH_PARENT CST_DSA.HIERARCHY_MISMATCHES :Q1002Cost: 0 Bytes: 905 Cardinality: 1
12 INDEX RANGE SCAN INDEX PARALLEL_COMBINED_WITH_PARENT SYS.HIERARCHY_MISMATCHES_IDX3 :Q1002Cost: 0 Cardinality: 1
16 INDEX RANGE SCAN INDEX PARALLEL_COMBINED_WITH_PARENT CST_DSA.IDX$$_06EF0001 :Q1002Cost: 1 Bytes: 5 Cardinality: 1 -
Issue in creation of group in oim database through sql query.
hi guys,
i am trying to create a group in oim database through sql query:
insert into ugp(ugp_key,ugp_name,ugp_create,ugp_update,ugp_createby,ugp_updateby,)values(786,'dbrole','09-jul-12','09-jul-12',1,1);
it is inserting the group in ugp table but it is not showing in admin console.
After that i also tried with this query:
insert into gpp(ugp_key,gpp_ugp_key,gpp_write,gpp_delete,gpp_create,gpp_createby,gpp_update,gpp_updateby)values(786,1,1,1,'09-jul-12',1,'09-jul-12',1);
After that i tried with this query.but still no use.
and i also tried to assign a user to the group through query:
insert into usg(ugp_key,usr_key,usg_priority,usg_create,usg_update,usg_createby,usg_updateby)values(4,81,1,'09-jul-12','09-jul-12',1,1);
But still the same problem.it is inserting in db.but not listing in admin console.
thanks,
hanuman.Hanuman Thota wrote:
hi vladimir,
i didn't find this 'ugp_seq'.is this a table or column?where is it?
It is a sequence.
See here for details on oracle sequences:
http://www.techonthenet.com/oracle/sequences.php
Most of the OIM database schema is created with the following script, located in the RCU distribution:
$RCU_HOME/rcu/integration/oim/sql/xell.sql
there you'll find plenty of sequence creation directives like:
create sequence UGP_SEQ
increment by 1
start with 1
cache 20
to create a sequence, and
INSERT INTO UGP (UGP_KEY, UGP_NAME, UGP_UPDATEBY, UGP_UPDATE, UGP_CREATEBY, UGP_CREATE,UGP_ROWVER, UGP_DATA_LEVEL, UGP_ROLE_CATEGORY_KEY, UGP_ROLE_OWNER_KEY, UGP_DISPLAY_NAME, UGP_ROLENAME, UGP_DESCRIPTION, UGP_NAMESPACE)
VALUES (ugp_seq.nextval,'SYSTEM ADMINISTRATORS', sysadmUsrKey , SYSDATE,sysadmUsrKey , SYSDATE, hextoraw('0000000000000000'), 1, roleCategoryKey, sysadmUsrKey, 'SYSTEM ADMINISTRATORS', 'SYSTEM ADMINISTRATORS', 'System Administrator role for OIM', 'Default');
as a sequence usage example.
Regards,
Vladimir -
Using a SQL Query in an Alert and Matching a String
I've created an alert in 12.0.4 using a SQL Query and the field that I'm trying to match is a string. Originally the query returned multiple rows but when the alert still didn't fire, I modified the query WHERE clause to return only one row:
NAME RESPONSE
Are area lights working? No
My expression in the metric is RESPONSE. In the Monitor I'm matching a string equal to No. (Do I need double quotes around the matchvalue? Single quotes? No quotes?) The metric is in the 15min scan group, the role is xMII Developers and I'm in that role. The monitor alert string is ' = '. Both metric and monitor are active and I've subscribed to the monitor. Other alerts in the 15min scan group (all based on tag queries) are firing off properly.
Why is nothing showing up in the Alert Log?
David MacindoeDavid,
Did you figure out the answer? If not, I will try to find someone to address your question.
Mike -
Use realational operators in an SQL query??????
does any one knows how to use realational operators in an SQL query??????
i wud like to do something like
select decode(2<3,sysdate,sydate +1) from dual
but i know decode does not supports relational operators......
thanx and Regards
amytYou can use a CASE statement which does support relational operators, or if you must use DECODE, then you can use something like:
SELECT DECODE(SIGN(2 - 3),-1,sysdate,sysdate - 1)
FROM dual;The SIGN function returns -1 if the expression is < 0, 1 if the expression is > 0 and 0 if the expression is 0. This works for numeric comparisions. You can use the GREATEST or LEAST functions in a similar fashion for character comparisions.
TTFN
John
Maybe you are looking for
-
Wifi drops constantly on WPA enterprise wifi on my campus
Hello, I own a macbook pro retina mid 2012 on maverick. The wifi drops constantly on campus, it's a WPA enterprise wifi. The wifi seems to work fine at home. My computer has been sent to an apple store twice for this issue already, I got it back but
-
Handling dynamic item data in VSTS
Hi Team, Can you please let us know how to handle dynamic item data in VSTS. Regards Raghavendra 8105577088
-
Air File is Damaged and is not Installing
Hello, When I try to install an Air Aplication in my computar I got the following error: Sorry, an error has occurred. This aplication could not be installed because the installer file is damaged. Try obteining a new installer file from the applicati
-
Apperture faster on old IMac than Mac Pro
OK so I've been slaving away for weeks in the studio using my 2.66 Quad core Mac Pro with 3GB RAM and putting up with slow, really slow performance from Aperture thinking that I really must upgrade my RAM. Then tonight I just want to look at some fam
-
So whenever I press play in logic express this huge black area takes over the screen behind the play head and moves along with the playhead. I don't know what to do to get rid of this huge black/dark display.