Help Modifying SQL Query
We just upgraded from Crystal Reports 8.0 to 2008 and are unable to modify the SQL query for any of our old Crystal Report files. I can view the query by going to "Database", "Show SQL Query..." but am unable to edit the SQL statement in any way.
If there a setting within "Options" or anywhere else that has this locked? Is there another place with the application that allows me to edit the SQL Query? I looked at the "Select Expert" but none of my WHERE elements show up there.
The SQL query cannot be modified. (It is my understanding that you could in older versions... Not sure in which version that changed.)
The latest versions of CR allow the use of SQL Commands. SQL Commands allow you to "paste" the SQL generated by CR and modify it or write your own SQL from scratch.
HTH,
Jason
Similar Messages
-
Need help with SQL Query with Inline View + Group by
Hello Gurus,
I would really appreciate your time and effort regarding this query. I have the following data set.
Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*20.00*-------------19
1234567----------11223--------------7/5/2008-----------Adjustment for bad quality---------44345563------------------A-----------------10.00------------19
7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765--------------------I---------------------30.00-------------19
Please Ignore '----', added it for clarity
I am trying to write a query to aggregate paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number. When there are no multiple records I want to display the respective Description.
The query should return the following data set
Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*10.00*------------19
7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765-------------------I---------------------30.00--------------19
The following is my query. I am kind of lost.
select B.Description, A.sequence_id,A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
from (
select sequence_id,check_date, check_number, invoice_number, sum(paid_amount) amount, vendor_number
from INVOICE
group by sequence_id,check_date, check_number, invoice_number, vendor_number
) A, INVOICE B
where A.sequence_id = B.sequence_id
Thanks,
NickIt looks like it is a duplicate thread - correct me if i'm wrong in this case ->
Need help with SQL Query with Inline View + Group by
Regards.
Satyaki De. -
Hi,
Please find my query below:
SELECT T2.STATUS
,COUNT(*) CNT
FROM (
SELECT T1.ID, MAX(T1.STATUS_ID) STATUS_ID
FROM TABLE1 T1
WHERE TRUNC(T1.START_DT) >= TO_DATE(RegisteredDateFrom,'dd/MM/yyyy')
AND TRUNC(T1.START_DT) <= TO_DATE(RegisteredDateTo,'dd/MM/yyyy')
AND (T1.STATUS IN ('100', '700','300'))
GROUP BY T1.ID
) Result1
LEFT JOIN TABLE2 T2 ON (Result1.STATUS_ID = T2.STATUS_ID)
GROUP BY T2.STATUS
This query returns me few rows along with the count for the specific time period.
I want to remove this date filter and provide this Start_DT as a slicer to the end user in Power Pivot. Also CNT should be the calculated based on the START_DT selection from the slicer.
Anybody help me to modify the query? I am not the query expert.
Thanks,
SSIt does not look like T-SQL syntax? Please ask people who work with Oracle.
https://community.oracle.com/community/developer/english/oracle_database/sql_and_pl_sql
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 -
HELP! SQL Query: Other ways to reorder column display?
I have a SQL query report with a large number of columns (users can hide/show columns as desired). It would be great if the column display order could be changed by changing the order of the columns in the SELECT list in the Report Definition, but that doesn't work -- it puts changed or added columns at the end regardless of the order in the SELECT list of the query.
Is there some other way to reorder the columns displayed without using the Report Attributes page? It's extremely tedious to move columns around using the up/down arrows which redisplays the page each time. Am I missing a way to change display order, or does anyone have a "trick" to do this? It's so painful....
When defining forms you can reoder columns by specifying a sequence number for each column. Just curious as to why reports were not done the same way, and are there any plans to address this in a future release?
KarenYes, reordering columns is extremely painful.
It is supposed to be much improved in the next version.
See
Re: Re-ordering columns on reports
Moving columns up/down in Report Attributes
See my example at
http://htmldb.oracle.com/pls/otn/f?p=24317:141
Basically, let the users move columns around until they are blue in the face, provide a Save button to save the column order in a user preference and reorder the columns when the page reloads.
Or you can use Carl's PL/SQL shuttle as the widget to specify the columns shown and their order. The shuttle is at http://htmldb.oracle.com/pls/otn/f?p=11933:27
Hope this helps.
Message was edited by:
Vikas -
Hi all,
I have data in the following manner:
CASE_NUMBER HOURS FLAG
1000 10 0
1000 20 0
1000 30 1
1000 40 0
1000 50 1
Here I need to Calculate the total hours for a Case_number till i see the flag as 1.
Here the result must be 10+20+30 Hrs
Another Example
CASE_NUMBER HOURS FLAG
2000 10 1
2000 20 1
Here the result must be only 10.
I am struggling to write a SQL query for this.
Anyones help will be very much greatful
Thanks in Advance
Regards,
Sengathir SubbarayanLook up analytical functions.
something like sum(hours) OVER (PARTITION BY case_number ORDER BY something)
will give you the sum for all rows.
Then you probably want to "throw away" those rows after the flag maybe by summing the flag column too, and throw away all those where the flag is greater than 1 and where it is equal to 1 except for the first one.
I suspect you actually have some other column (other than the number of hours) that define your order - that's what you put in the ORDER BY.
Jon -
Hi,
I need a help in writing an SQL query . I am actually confused how to write a query. Below is the scenario.
CREATE TABLE demand_tmp
( item_id NUMBER,
org_id NUMBER,
order_line_id NUMBER,
quantity NUMBER,
order_type NUMBER
CREATE TABLE order_tmp
( item_id NUMBER,
org_id NUMBER,
order_line_id NUMBER,
open_flag VARCHAR2(10)
INSERT INTO demand_tmp
SELECT 12438,82,821,100,30 FROM dual;
INSERT INTO demand_tmp
SELECT 12438,82,849,350,30 FROM dual;
INSERT INTO demand_tmp
SELECT 12438,82,NULL,150,29 FROM dual;
INSERT INTO demand_tmp
SELECT 12438,82,0,50,-1 FROM dual;
INSERT INTO order_tmp
SELECT 12438,82,821,'Y' FROM dual;
INSERT INTO order_tmp
SELECT 12438,82,849,'N' FROM dual;
Demand_tmp:
Item_id org_id order_line_id quantity order_type
12438 82 821 100 30
12438 82 849 350 30
12438 82 NULL 150 29
12438 82 0 50 -1
Order_tmp :
Item_id org_id order_line_id open_flag
12438 82 821 Y
12438 82 849 N I need to fetch the records from demand_tmp table whose order_line_id is present in order_tmp and having open_flag as 'Y' or if order_type in demand_tmp table is 29.
The below query will give the records whose order line id is present in order_tmp. But, If i need records which are having order_type=29 the below query wont return any records as order_line_id is NULL. If I place outer join I will get other records also (In this example order_type -1 records) . Please help me how can we write a query for this. Expected o/p is below.
Query :
Select item_id,org_id,order_line_id,quantity,order_type,open_flag
from demand_tmp dt , order_tmp ot
where dt.order_line_id = ot.order_line_id
AND dt.item_id=ot.item_id
AND dt.org_id = ot.org_id
AND ot.open_flag = 'Y';
Expected Output :
item_id org_id order_line_id quantity order_type open_flag
12438 82 821 100 30 Y
12438 82 NULL 150 29 NULL Thanks in advance,
Rakesh
Edited by: Venkat Rakesh on Oct 7, 2012 6:32 PM
Edited by: Venkat Rakesh on Oct 7, 2012 8:39 PMHi Rakesh,
the query is not working as you would like ( but IS working as expected ) since your trying to compare null to another value.
Comparing null always results in FALSE, also if you compare null to null. This is because null means undefined.
select 1 from dual where null=null results in no data found.
I would suggest using a non natural key to join the tables.
For example include a column ID in the master table which is filled with a sequence and include that field as a foreign key in the detail table.
This way you can easily join master and detail on ID = ID, and you don't have to worry about null values in this column since it's always filled with data.
Regards,
Bas
btw, using the INNER JOIN and OUTER JOIN syntax in your SQL makes it better readable, since you're separating join conditions from the where clause, just a tip ;) -
Help with SQL query invloving time operations
I have created 2 tables in my SQL. One is the user_info table which stores the time of login and timezone of login for each user. The other is the post_table which stores the postid, user who makes the post, time of post and timezone for each posts.
CREATE TABLE user_info
user_id VARCHAR(20),
login_date DATE,
login_time_zone VARCHAR(20),
PRIMARY KEY (user_id)
CREATE TABLE post_table
post_id VARCHAR(20),
user_id VARCHAR(20),
datepost DATE,
time_zone VARCHAR(20),
PRIMARY KEY (post_id),
FOREIGN KEY (user_id) REFERENCES user_info(user_id) ON DELETE CASCADE
) ;Some sample data for my tables is as below -
INSERT INTO user_info VALUES( 'u1', to_date('9/17/2009 20:00','MM/DD/YYYY mi:ss'), -2 );
INSERT INTO user_info VALUES( 'u2', to_date('9/17/2009 19:55','MM/DD/YYYY mi:ss'), -4 );
INSERT INTO post_table VALUES( 'p1', 'u1', to_date('9/17/2009 20:50','MM/DD/YYYY mi:ss'), 6 );
INSERT INTO post_table VALUES( 'p2', 'u2', to_date('9/17/2009 20:30','MM/DD/YYYY mi:ss'), -5 );
INSERT INTO post_table VALUES( 'p3', 'u2', to_date('9/18/2009 6:00','MM/DD/YYYY mi:ss'), 2 );
INSERT INTO post_table VALUES( 'p4', 'u1', to_date('9/17/2009 21:00','MM/DD/YYYY mi:ss'), -3 );I need to write an SQL query which - finds the user(s) whose time difference between the login time and the latest time when he/she writes a post is the smallest. I need to consider the timezones here as well.
I am unsure if time_zone should be of type VARCHAR or TIMESTAMP so have created it as VARCHAR in my tables.
Someone please help me form this query.
PS : How do I user <code> tags in this forum to write sql statements.
Edited by: user11994430 on Oct 9, 2009 5:59 PMI tried with the following test data
INSERT INTO user_info VALUES( 'u1', to_date('9/17/2009 20:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO user_info VALUES( 'u2', to_date('9/16/2009 13:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO user_info VALUES( 'u3', to_date('9/18/2009 15:00','MM/DD/YYYY mi:ss'), 0 );
INSERT INTO user_info VALUES( 'u4', to_date('9/20/2009 17:00','MM/DD/YYYY mi:ss'), 0 );
INSERT INTO user_info VALUES( 'u5', to_date('9/14/2009 3:00','MM/DD/YYYY mi:ss'), -3 );
INSERT INTO user_info VALUES( 'u6', to_date('9/15/2009 6:00','MM/DD/YYYY mi:ss'), -3 );
INSERT INTO user_info VALUES( 'u7', to_date('9/16/2009 7:00','MM/DD/YYYY mi:ss'), 0 );
INSERT INTO user_info VALUES( 'u8', to_date('9/17/2009 8:00','MM/DD/YYYY mi:ss'), -8 );
INSERT INTO user_info VALUES( 'u9', to_date('9/18/2009 9:00','MM/DD/YYYY mi:ss'), 0 );
INSERT INTO user_info VALUES( 'u10', to_date('9/19/2009 10:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO user_info VALUES( 'u11', to_date('9/20/2009 11:00','MM/DD/YYYY mi:ss'), -5 );
INSERT INTO user_info VALUES( 'u12', to_date('9/21/2009 19:00','MM/DD/YYYY mi:ss'), -8 );
INSERT INTO user_info VALUES( 'u13', to_date('9/1/2009 4:00','MM/DD/YYYY mi:ss'), -3 );
INSERT INTO user_info VALUES( 'u14', to_date('9/22/2009 7:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO user_info VALUES( 'u15', to_date('9/24/2009 23:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO user_info VALUES( 'u16', to_date('9/25/2009 11:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO user_info VALUES( 'u17', to_date('9/26/2009 18:00','MM/DD/YYYY mi:ss'), -4 );
INSERT INTO user_info VALUES( 'u18', to_date('9/27/2009 13:00','MM/DD/YYYY mi:ss'), -8 );
INSERT INTO user_info VALUES( 'u19', to_date('9/17/2009 18:00','MM/DD/YYYY mi:ss'), -5 );
INSERT INTO user_info VALUES( 'u20', to_date('9/29/2009 22:00','MM/DD/YYYY mi:ss'), -8 );
INSERT INTO user_info VALUES( 'u21', to_date('9/30/2009 5:00','MM/DD/YYYY mi:ss'), -8 );
INSERT INTO user_info VALUES( 'u22', to_date('9/15/2009 7:00','MM/DD/YYYY mi:ss'), -4 );
INSERT INTO user_info VALUES( 'u23', to_date('9/16/2009 17:00','MM/DD/YYYY mi:ss'), -8 );
INSERT INTO user_info VALUES( 'u24', to_date('9/17/2009 19:00','MM/DD/YYYY mi:ss'), 0 );
INSERT INTO user_info VALUES( 'u25', to_date('9/18/2009 22:00','MM/DD/YYYY mi:ss'), -5 );
INSERT INTO user_info VALUES( 'u26', to_date('9/19/2009 15:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO user_info VALUES( 'u27', to_date('9/20/2009 23:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO post_table VALUES('p1', 'u26', to_date('9/14/2009 18:00','MM/DD/YYYY mi:ss'), -5 ) ;
INSERT INTO post_table VALUES('p2', 'u2', to_date('7/1/2009 15:00','MM/DD/YYYY mi:ss'), 1 ) ;
INSERT INTO post_table VALUES('p3', 'u2', to_date('7/20/2009 20:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO post_table VALUES('p4', 'u5', to_date('7/20/2009 22:00','MM/DD/YYYY mi:ss'), 1) ;
INSERT INTO post_table VALUES( 'p5', 'u2', to_date('7/21/2009 10:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO post_table VALUES( 'p6', 'u8', to_date('8/1/2009 20:00','MM/DD/YYYY mi:ss'), -8 );
INSERT INTO post_table VALUES( 'p7', 'u10', to_date('5/3/2009 15:00','MM/DD/YYYY mi:ss'), -3 ) ;
INSERT INTO post_table VALUES( 'p8', 'u25', to_date('9/15/2009 20:00','MM/DD/YYYY mi:ss'), -5 ) ;
INSERT INTO post_table VALUES( 'p9', 'u6', to_date('9/7/2009 19:00','MM/DD/YYYY mi:ss'), -3 ) ;
INSERT INTO post_table VALUES( 'p10', 'u10', to_date('7/22/2009 10:00','MM/DD/YYYY mi:ss'), 1 ) ;
INSERT INTO post_table VALUES( 'p11', 'u9', to_date('7/7/2009 13:00','MM/DD/YYYY mi:ss'), 0) ;
INSERT INTO post_table VALUES( 'p12', 'u2', to_date('7/30/2009 11:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO post_table VALUES( 'p13', 'u10', to_date('7/22/2009 8:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO post_table VALUES( 'p14', 'u6', to_date('5/30/2009 23:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO post_table VALUES( 'p15', 'u3', to_date('5/31/2009 2:00','MM/DD/YYYY mi:ss'), 0 ) ;
INSERT INTO post_table VALUES( 'p16', 'u12', to_date('6/20/2009 7:00','MM/DD/YYYY mi:ss'), -8 ) ;
INSERT INTO post_table VALUES( 'p17', 'u20', to_date('6/20/2009 9:00','MM/DD/YYYY mi:ss'), -8) ;
INSERT INTO post_table VALUES( 'p18','u27', to_date('9/15/2009 11:00','MM/DD/YYYY mi:ss'), -5 );
INSERT INTO post_table VALUES( 'p19','u26', to_date('7/1/2009 20:00','MM/DD/YYYY mi:ss'), 0 ) ;
INSERT INTO post_table VALUES( 'p20', 'u25', to_date('7/2/2009 17:00','MM/DD/YYYY mi:ss'), -5 );
INSERT INTO post_table VALUES( 'p21', 'u27', to_date('7/3/2009 20:00','MM/DD/YYYY mi:ss'), 1) ;
INSERT INTO post_table VALUES( 'p22', 'u2', to_date('9/15/2009 13:00','MM/DD/YYYY mi:ss'), 1 ) ;
INSERT INTO post_table VALUES( 'p23', 'u21', to_date('5/30/2009 17:00','MM/DD/YYYY mi:ss'), -8 );
INSERT INTO post_table VALUES( 'p24', 'u25', to_date('8/30/2009 20:00','MM/DD/YYYY mi:ss'), -5 );
INSERT INTO post_table VALUES( 'p25', 'u18', to_date('9/13/2009 18:00','MM/DD/YYYY mi:ss'), -8 );
INSERT INTO post_table VALUES( 'p26', 'u11', to_date('9/9/2009 13:00','MM/DD/YYYY mi:ss'), -8 );
INSERT INTO post_table VALUES( 'p27', 'u23', to_date('9/10/2009 1:00','MM/DD/YYYY mi:ss'), -5 );
INSERT INTO post_table VALUES( 'p28', 'u22', to_date('9/10/2009 14:00','MM/DD/YYYY mi:ss'), -4 );The output I get is
USER_ID
u25
u9
u20
u5
u27
u8
u21
u23
u22
u26
u10
USER_ID
u3
u12
u18
u2
u6
u11
17 rows selected. -
Modify SQL query in Crystal Reports 2013
Bonjour,
Je voulais savoir s'il était possible de modifier la requête SQL dans Crystal Reports 2013, car les bases de données de notre application pour bibliothèque utilise un format de date particulier qu'il nous faut corriger directement dans la requête SQL.
Merci pour vos informations.
Cordialement
Claude Marcilly
Cannes - France
Hello,
I wanted to know if it was possible to modify the SQL query in Crystal Reports 2013. Databases of our application library indeed use a particular date format that we need to fix directly into the SQL query.
Thank you for your information.
Best regards
Claude Marcilly
Cannes - FranceHi Claude,
If you are creating reports using tables then go in Database menu and click on show SQL query, this will show the SQL generated by crystal reports. Now go in database expert and expend your connection and double click on Add Command and past the query which was generated by Crystal and try to modify the date format and click OK.
Now you need to redesign your reports based on Add command.
or
If your reports datasource is Add command you can directly go in add command and change it.
-Sastry -
Hi,
Can the below SQL Query be modified in any simpler way.
IF (V_BillingTypeID = 2) THEN
select count(*)
into V_AuthCount
from payerauthorization pa
where pa.patientidentificationno = IV_PatientIdentifierno
and pa.registrationno = IV_UHID;
if (V_AuthCount > 0) then
select pa.responsetype, pa.payerapprovedamount
into V_ResponseType, V_ApprovedAmt
from payerauthorization pa
where pa.patientidentificationno = IV_PatientIdentifierno
and pa.registrationno = IV_UHID;
if V_ResponseType = 3 then
V_ServiceTariff := V_ServiceTariff -
(V_ServiceTariff * (V_ApprovedAmt / 100));
end if;
if V_ResponseType = 2 then
select (pb.totalbillamount + pb.discountamount)
into V_GrossBillAmt
from patientbill pb
where pb.billno = IV_BillNo;
V_AuthPercentage := ((V_ApprovedAmt / V_GrossBillAmt) * 100);
V_ServiceTariff := round(V_ServiceTariff -
(V_AuthPercentage *
(V_ServiceTariff / 100)));
end if;
if V_ResponseType = 5 then
select (pb.totalbillamount + pb.discountamount)
into V_GrossBillAmt
from patientbill pb
where pb.billno = IV_BillNo;
V_AuthPercentage := ((V_ApprovedAmt / V_GrossBillAmt) * 100);
V_ServiceTariff := round(V_ServiceTariff -
(V_AuthPercentage *
(V_ServiceTariff / 100)));
end if;
end if;
select Count(*)
into V_CRCount
from creditnote cr
where cr.billno = iv_Billno;
if (V_CRCount > 0) then
select cr.creditnoteamount
into V_RefundedAmount
from creditnote cr
where cr.billno = iv_Billno;
end if;
SELECT SUM(GC.REFUNDAMOUNT) INTO V_GCREFUNDAMOUNT FROM GBCREDITNOTE GC;
V_MAXREFUNDAMOUNT := (V_PatientPaidAmount - (NVL(V_GCREFUNDAMOUNT, 0) +
NVL(V_RefundedAmount, 0)));
END IF;Thanks in advance.Few things i came across are
1. You could remove the query where you do COUNT() just to check if data exist before SELECT..INTO. You can use EXCEPTION handling insted.
2. The condition V_ResponseType = 2 adn V_ResponseType = 5 looks same so you can combine it into a single condition.
I have modified it like this.
if (v_billingtypeid = 2) then
begin
select pa.responsetype
, pa.payerapprovedamount
into v_responsetype
, v_approvedamt
from payerauthorization pa
where pa.patientidentificationno = iv_patientidentifierno
and pa.registrationno = iv_uhid;
if v_responsetype = 3 then
v_servicetariff := v_servicetariff - (v_servicetariff * (v_approvedamt / 100));
end if;
if v_responsetype in (2, 5) then
select (pb.totalbillamount + pb.discountamount)
into v_grossbillamt
from patientbill pb
where pb.billno = iv_billno;
v_authpercentage := ((v_approvedamt / v_grossbillamt) * 100);
v_servicetariff := round(v_servicetariff -(v_authpercentage *(v_servicetariff / 100)));
end if;
exception
when no_data_found then
null;
end;
begin
select cr.creditnoteamount
into v_refundedamount
from creditnote cr
where cr.billno = iv_billno;
exception
when no_data_found then
null;
end;
select sum(gc.refundamount)
into v_gcrefundamount
from gbcreditnote gc;
v_maxrefundamount := (v_patientpaidamount - (nvl(v_gcrefundamount, 0) + nvl(v_refundedamount, 0)));
end if;Edited by: Karthick_Arp on Feb 21, 2013 3:26 AM
Fixed BEGIN..END mismatch. -
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. -
I have a table with Columns as as below
id number primary key
object_name varchar2(100)
object_value varchar2(100)
Data is stored as follows
id object_name object_value
10 prop_num 436
20 city dallas
40 Misc 1 90
50 Misc 1 desc min amount
60 Misc 2 700
70 Misc 2 desc interest amount
80 Misc 3
80 Misc 3 desc
SQL should return result as shown below
id object_name object_value
10 prop_num 436
20 city dallas
40 min amount 90
50 interest amount 700
I have done this through plsql code by creating temp table. But I need to do it in a sql query. I am stuck here
Any pointers/help is appreciated
Thanks
Edited by: user9327712 on Mar 11, 2010 8:14 AMI have a table where the ids are stored.
*"object name"* column values are actually another table columns stored as rows here. So in our example prop_num, city,Misc 1, Misc 1 desc, Misc 2, Misc 2
desc,Misc 3 , Misc 3 desc are all columns. These would not change any time
The column object_value has values stored for respective columns.
436, dallas , 90 , min amount , 700 , interest amount are all column values. So these can change.
id object_name object_value
10 prop_num 436
20 city dallas
40 Misc 1 90
50 Misc 1 desc min amount
60 Misc 2 700
70 Misc 2 desc interest amount
80 Misc 3
90 Misc 3 desc
Edited by: user9327712 on Mar 11, 2010 9:57 AM
Edited by: user9327712 on Mar 11, 2010 10:00 AM
Edited by: user9327712 on Mar 11, 2010 10:00 AM -
Hi All,
I need help to get a sql query for included dates
I have this scenario
create table test (names varchar2(100),start_date date,end_date date,exc_flg number);
insert into test values('John',to_date('01-jan-2009','dd-mon-yyyy'),to_date('31-dec-2011','dd-mon-yyyy'),0);
insert into test values('John',to_date('01-jan-2009','dd-mon-yyyy'),to_date('31-dec-2010','dd-mon-yyyy'),1);
insert into test values('Joseph',to_date('01-jan-2009','dd-mon-yyyy'),to_date('31-dec-2011','dd-mon-yyyy'),0);
insert into test values('Jack',to_date('01-jan-2009','dd-mon-yyyy'),to_date('31-dec-2010','dd-mon-yyyy'),0);
In the above case john is included for this duration start_date is '01-jan-2009' and end_date is '31-dec-2011' and is excluded for this duration '01-jan-2009','31-dec-2010'
Now i want to dispay John's incuded duration as ''01-jan-2011','31-dec-2011'
My sql output should be
Names start_date end_date
John 01-jan-2011 31-dec-2011
Joseph 01-jan-2009 31-dec-2011
Jack 01-jan-2009 31-dec-2010
Thanks in AdvanceHi there,
seems like the old "find those time gaps" problem. I tried to solve it in pure SQL, and since it's Monday I didn't want to wrap my mind around the MODEL clause,
therefore my solution looks a bit cluttered - feel free to improve.
create table test (names varchar2(100),start_date date,end_date date,exc_flg number);
INSERT INTO TEST VALUES('John',to_date('01-01-2009','dd-mm-yyyy'),to_date('31-12-2011','dd-mm-yyyy'),0);
INSERT INTO TEST VALUES('John',to_date('01-01-2009','dd-mm-yyyy'),to_date('31-12-2010','dd-mm-yyyy'),1);
INSERT INTO TEST VALUES('John',to_date('01-04-2011','dd-mm-yyyy'),to_date('01-07-2011','dd-mm-yyyy'),1);
INSERT INTO TEST VALUES('Joseph',to_date('01-01-2009','dd-mm-yyyy'),to_date('31-12-2011','dd-mm-yyyy'),0);
INSERT INTO TEST VALUES('Jack',to_date('01-01-2009','dd-mm-yyyy'),to_date('31-12-2010','dd-mm-yyyy'),0);
INSERT INTO TEST VALUES('Joe',to_date('01-01-2009','dd-mm-yyyy'),to_date('31-12-2011','dd-mm-yyyy'),0);
INSERT INTO TEST VALUES('Joe',to_date('01-04-2010','dd-mm-yyyy'),to_date('31-12-2011','dd-mm-yyyy'),0);
INSERT INTO TEST VALUES('Joe',to_date('01-01-2008','dd-mm-yyyy'),to_date('31-12-2009','dd-mm-yyyy'),1);
select * from test;
WITH t AS (SELECT names
, 's' flg_date
, start_date dat
FROM TEST
WHERE exc_flg = 0
UNION ALL
SELECT names
, 'e'
, end_date
FROM TEST
WHERE exc_flg = 0
UNION ALL
SELECT names
, 's'
, end_date + 1
FROM TEST
WHERE exc_flg = 1
UNION ALL
SELECT names
, 'e'
, start_date - 1
FROM TEST
WHERE exc_flg = 1
, t2 AS (SELECT t.*
, DECODE(LAG(t.flg_date) OVER (PARTITION BY t.names ORDER BY t.dat), flg_date, 0, NULL, 1, 1) grp_date
FROM t
WHERE NOT EXISTS (SELECT 1
FROM TEST t2
WHERE t2.names = t.names
AND exc_flg = 1
AND t.dat BETWEEN t2.start_date AND t2.end_date)
AND t.dat BETWEEN (SELECT MIN(start_date)
FROM TEST t2
WHERE t2.names = t.names
AND exc_flg = 0)
AND (SELECT MAX(end_date)
FROM TEST t2
WHERE t2.names = t.names
AND exc_flg = 0)
, t3 AS (SELECT t2.names
, t2.flg_date
, t2.dat
, SUM(grp_date) OVER (PARTITION BY t2.names ORDER BY t2.dat) grp_date
FROM t2
, t4 AS (SELECT t3.*
, row_number() OVER (PARTITION BY t3.names, t3.grp_date ORDER BY t3.dat) rn_start_date
, row_number() OVER (PARTITION BY t3.names, t3.grp_date ORDER BY t3.dat DESC) rn_end_date
FROM t3
SELECT names
, dat
, nxt_dat
FROM (SELECT t4.names
, dat
, CASE WHEN t4.flg_date = 's' THEN LEAD(dat) OVER (PARTITION BY t4.names ORDER BY t4.dat) END nxt_dat
FROM t4
WHERE (t4.flg_date = 's' AND rn_start_date = 1)
OR (t4.flg_date = 'e' AND rn_end_date = 1)
WHERE nxt_dat IS NOT NULL
ORDER BY names, dat
NAMES DAT NXT_DAT
Jack 2009.01.01 00:00:00 2010.12.31 00:00:00
Joe 2010.01.01 00:00:00 2011.12.31 00:00:00
John 2011.01.01 00:00:00 2011.03.31 00:00:00
John 2011.07.02 00:00:00 2011.12.31 00:00:00
Joseph 2009.01.01 00:00:00 2011.12.31 00:00:00C. -
Complete novice needs help getting SQL Query into Crystal Reports XI
Post Author: MissMarnie
CA Forum: Data Connectivity and SQL
So I was given an intro level web course and a monster reference guide in prep to format a report. One of our developers wrote me everything I need for the report into a SQL Query and now I'm supposed to format it in CR XII literally do not know what to do from here. I'm able to set up the correct server as a datasource, if that's useful, but I don't know how to make the querey into a bunch of formattable fields in CR. If anyone can walk me through this, I'd be so grateful. I've attempted to look up SQL query in both the help and the book but I keep hitting a wall. The help dialog says things like "press this button" with no reference to what "this button" is. I'm sure it's obvious to the knowledgeable but I'm in a complete fog. Thanks in advancePost Author: synapsevampire
CA Forum: Data Connectivity and SQL
IF you're trying to get assistance with setting up a query as the source for a report, try posting your Crystal version and the database type.
Different software works differently.
In CR 9 and above, under the connection to the database you'll see Add Command. Select that and you can paste the query in.
As for not knowing how to generate a report, that requires experience, there's no generic solution of course..
-k -
URgent: Help regarding SQL Query
Hi ,
I need help regarding an sql query.
Sample Data:
ITEM_TYPE ITEM_NUM UNIT_PRICE QUANTITY LINE_TOTAL
ITEM 1 5 10 50
ITEM 2 10 5 50
ITEM 1 5 5 25
ITEM 2 10 20
TAX 16.5
TAX -3.5I would like to display the data as
ITEM_TYPE ITEM_NUM UNIT_PRICE QUANTITY LINE_TOTAL
ITEM 1 5 15 145
2 10 5
2 10
TAX 13.0
Line_total = unit_price * QuantityThanks in Advance
G.Vamsi Krishna
Edited by: user10733211 on Aug 5, 2009 7:42 AM
Edited by: user10733211 on Aug 5, 2009 7:49 AM
Edited by: user10733211 on Aug 5, 2009 8:12 AM
Edited by: user10733211 on Aug 5, 2009 8:22 AM
Edited by: user10733211 on Aug 5, 2009 8:24 AMHi,
Try this, use some analytics:
SQL> with t as (
2 select 'item' item_type, 1 item_num, 5 unit_price, 10 quantity, 50 linetotal from dual union all
3 select 'item', 2, 10, 5, 50 from dual union all
4 select 'item', 1, 5, 5, 25 from dual union all
5 select 'item', null, 2, 10, 20 from dual union all
6 select 'tax', null, null, null, 16.5 from dual union all
7 select 'tax', null, null, null, -3.5 from dual
8 ) -- actual query starts here:
9 select item_type
10 , item_num
11 , unit_price
12 , sum_qty
13 , case when sum_lt = lag(sum_lt) over ( order by item_type, item_num )
14 then null
15 else sum_lt
16 end sum_lt
17 from ( select item_type
18 , item_num
19 , unit_price
20 , quantity
21 , sum(quantity) over ( partition by item_type, item_num ) sum_qty
22 , sum(linetotal) over ( partition by item_type ) sum_lt
23 , row_number() over ( partition by item_type, item_num order by item_type, item_num ) rn
24 from t
25 )
26 where rn=1;
ITEM ITEM_NUM UNIT_PRICE SUM_QTY SUM_LT
item 1 5 15 145
item 2 10 5
item 2 10
tax 13
4 rows selected.
edit
And please use the code tag, instead of clunging with concats.
Read:
http://forums.oracle.com/forums/help.jspa
Edited by: hoek on Aug 5, 2009 5:15 PM
edit2
Also nulls for item_type:
ops$xmt%OPVN> with t as (
2 select 'item' item_type, 1 item_num, 5 unit_price, 10 quantity, 50 linetotal from dual union all
3 select 'item', 2, 10, 5, 50 from dual union all
4 select 'item', 1, 5, 5, 25 from dual union all
5 select 'item', null, 2, 10, 20 from dual union all
6 select 'tax', null, null, null, 16.5 from dual union all
7 select 'tax', null, null, null, -3.5 from dual
8 ) -- actual query starts here:
9 select case when item_type = lag(item_type) over ( order by item_type, item_num )
10 then null
11 else sum_lt
12 end item_type
13 , item_num
14 , unit_price
15 , sum_qty
16 , case when sum_lt = lag(sum_lt) over ( order by item_type, item_num )
17 then null
18 else sum_lt
19 end sum_lt
20 from ( select item_type
21 , item_num
22 , unit_price
23 , quantity
24 , sum(quantity) over ( partition by item_type, item_num ) sum_qty
25 , sum(linetotal) over ( partition by item_type ) sum_lt
26 , row_number() over ( partition by item_type, item_num order by item_type, item_num ) rn
27 from t
28 )
29 where rn=1;
ITEM_TYPE ITEM_NUM UNIT_PRICE SUM_QTY SUM_LT
145 1 5 15 145
2 10 5
2 10
13 13
4 rows selected.If you really need a space instead of nulls, then simply replace the nulls by a space....
Edited by: hoek on Aug 5, 2009 5:18 PM -
Help with sql query the status of A/P Reserve Invoice
Hi,
I am trying to write a query which lists all A/P Reserve Invoice info with OPEN status.
I check the OPCH table and cannot find the rule to tell the status.
The "DocStatus" field has two values only: 'O' for open and 'C' for closed.
However, the status of A/P Reserve Invoice are OPEN, CLOSED, DELIVERED, PAID, etc.
I try to use DocStatus field to filter, but the result does not match what I see in SAP.
Could you please give me some hints about how to get the data I need? Thank you.
Best regards,
Sylvia
Edited by: csylvia on Jun 23, 2011 5:54 AMHi Darius,
Thanks for your reply.
However, I don't know what is the relationship between Purchase order and A/P Reserve Invoice.
Do you mean using "SELECT T0.DocEntry FROM OPCH T0, OPOR T1 WHERE T0.DocNum = T1.DocNum AND T1.DocStatus = 'O';" to query the A/P Reserve Invoice data with OPEN status?
But the result is not what I want.
The result of "*SELECT * FROM OPOR WHERE DocStatus = 'O';*" is also not.
I'd like to query A/P Reserve Invoice list with OPEN status, and I try the following sql query:
SELECT DocEntry FROM OPCH WHERE DocStatus = 'O' AND InvntSttus = 'O';
The result is close to what I need, but it's not exactly correct.
Moreover, I don't think the sql query conditions is accurate.
Please give me some advice. Thank you.
Best regards,
Sylvia
Maybe you are looking for
-
Date issue in processing billing documents that shipped in a prior period
Date issue in processing billing documents that shipped in a prior period that is now closed: SAP values those deliveries with the current document date in A/R when it should be the original delivery date. Baseline date needs to stay the delivery da
-
Select Single * is not fetching all Data
Hi, I have a peculiar problem, when i am extending the customer to a new company code, we are getting Dump saying 'ASSERTION_FAILED' when i debugg i am geeting issue with following Code of a FM 'KNA1_SINGLE_READER' IF NOT i_bypassing_buffer IS INITIA
-
Smart form footer issue in 2nd page - Horizontal line is not displayed
Dear Experts, I am working on a smartform. Which has a table (Header, Main area, Footer), When there are more records and footer alone is printed in the 2nd page, i am not getting the first horizontal line for the footer and it does not look like a t
-
Hey I am trying to compile a simple as3 file [code] package { import flash.display.MovieClip; class Test extends MovieClip{ public function Test(){ trace("Hello"); [/code] It compiles ( with a warning) but I get this runtime error TextReferenceError:
-
Export\Import WSUS Updates
Hi I have a Q about export\import process in WSUS(3.2). I have a primary WSUS server that I`ve exported all updates from and imported all updates to a disconnected WSUS server. now I have some new updates that I need to export and import. my question