Am trying to create pivot table by using Auto it tool, can anyone help to complete this code,need to add field in Columns , Rows and Value
below code just adding field in Filters
$oExcel = ObjCreate("Excel.Application")
$oExcel.Visible = 1
$oExcel.WorkBooks.Open ("C:\AR\Deptwise AR-20.03.2017.xlsx")
$test = $oExcel.ActiveWorkbook.PivotCaches.Create(1,"A1:Y11795",1)
$oExcel.Sheets.Add
$test2 = $oExcel.Range("A1:Y11795")
$oExcel.ActiveSheet.PivotTables.Add($test,$test2,"GCI")
$oExcel.Application.ActiveSheet.PivotTables("GCI").PivotFields("GCI").Orientation = 3
$oExcel.ActiveSheet.PivotTables ("PivotTable5" ).PivotCache.Refresh
Related
I am new to progress 4gl and below is the query used to add all fields from a table to dynamic temp table except few fields but I am not sure how to add only required fields to dynamic temp table. Please help to modify the query I shared.
/* p-ttdyn2.p - a join of 2 tables */
DEFINE VARIABLE tth4 AS HANDLE.
DEFINE VARIABLE btth4 AS HANDLE.
DEFINE VARIABLE qh4 AS HANDLE.
DEFINE VARIABLE bCust AS HANDLE.
DEFINE VARIABLE bOrder AS HANDLE.
DEFINE VARIABLE i AS INTEGER.
DEFINE VARIABLE fldh AS HANDLE EXTENT 15.
bCust = BUFFER customer:HANDLE.
bOrder = BUFFER order:HANDLE.
CREATE TEMP-TABLE tth4.
tth4:ADD-FIELDS-FROM(bCust,"address,address2,phone,city,comments").
tth4:ADD-FIELDS-FROM(bOrder,"cust-num,carrier,instructions,PO,terms").
tth4:TEMP-TABLE-PREPARE("CustOrdJoinTT").
btth4 = tth4:DEFAULT-BUFFER-HANDLE.
FOR EACH customer WHERE cust.cust-num < 6, EACH order OF customer:
btth4:BUFFER-CREATE.
btth4:BUFFER-COPY(bCust).
btth4:BUFFER-COPY(bOrder).
END.
/* Create Query */
CREATE QUERY qh4.
qh4:SET-BUFFERS(btth4).
qh4:QUERY-PREPARE("for each CustOrdJoinTT").
qh4:QUERY-OPEN.
REPEAT WITH FRAME zz DOWN:
qh4:GET-NEXT.
IF qh4:QUERY-OFF-END THEN LEAVE.
REPEAT i = 1 TO 15:
fldh[i] = btth4:BUFFER-FIELD(i).
DISPLAY fldh[i]:NAME FORMAT "x(15)"
fldh[i]:BUFFER-VALUE FORMAT "x(20)".
END.
END.
btth4:BUFFER-RELEASE.
DELETE OBJECT tth4.
DELETE OBJECT qh4.
ADD-FIELDS-FROM only supports excluding fields that are not needed. Instead you can use ADD-LIKE-FIELD multiple times:
CREATE TEMP-TABLE tth4.
tth4:ADD-LIKE-FIELD("address", "customer.address").
tth4:ADD-LIKE-FIELD("address2", "customer.address2").
tth4:ADD-LIKE-FIELD("phone", customer.phone").
...
tth4:ADD-LIKE-FIELD("cust-num", "Order.cust-num").
...
tth4:TEMP-TABLE-PREPARE("CustOrdJoinTT").
btth4 = tth4:DEFAULT-BUFFER-HANDLE.
Depending on your use case, you can also invert the required field list to an except field list:
var handle ht,hb.
var longchar lcjson.
function invertFields returns character (
i_hb as handle,
i_crequired as char
):
var char cexcept,cfield.
var int ic.
do ic = 1 to i_hb:num-fields:
cfield = i_hb:buffer-field( ic ):name.
if lookup( cfield, i_crequired ) = 0 then
cexcept = cexcept + ',' + cfield.
end.
return substring( cexcept, 2 ).
end function.
create temp-table ht.
ht:add-fields-from(
buffer customer:handle,
invertFields( buffer customer:handle, "CustNum,Name" )
).
ht:temp-table-prepare( 'tt' ).
hb = ht:default-buffer-handle.
hb:buffer-create().
assign
hb::CustNum = 1
hb::Name = 'test'
.
hb:write-json( 'longchar', lcjson, true ).
message string( lcjson ).
https://abldojo.services.progress.com/?shareId=624993253fb02369b25437c4
I want to update my geometry(point) column with latitude(float) and longitude(float) column.
Table PK column is pk.
I tried to query
update ucs.target1
set geo_point = st_geomfromtext('point(latitude longitude)')
where pk = 'gd'
but syntax error occured.
help me plz....
An alternative way, try this one by specifying the srid (in here for example for WGS84):
update ucs.target1
set geo_point = st_geomfromtext('point(longitude latitude)',4326)
where pk = 'gd'
I edit my answer here:
Suppose I have table with its structure :
CREATE TABLE schema.table_name
(
id integer NOT NULL,
geom_4326 geometry(Point,4326)
)
Table have already rows, and I want to update the coordinate at a specific id, in here id = 'id_value'.
My code is :
update schema.table_name
SET geo_point = ST_SetSRID(ST_MakePoint(longitude,latitude), SRID)
where id = 'id_value'
SRID in my case = 4326
The join returns the view I want but when I go to create the table I get 0 rows processed. I'm sure I'm missing something simple but this is my first time creating tables using queries. Help is appreciated.
THE JOIN:
Select
a.*,
b.acct_sk,
b.voice_estbd_dt,
b.data_estbd_dt,
b.video_estbd_dt,
b.voice_term_dt,
b.data_term_dt,
b.video_term_dt,
b.voice_svc_type_id,
b.voice_acct_status_id,
b.data_svc_type_id,
b.data_acct_status_id,
b.video_svc_type_id,
b.video_acct_status_id,
b.video_svc_type,
b.data_down_spd_mb,
b.data_up_spd_mb,
b.dsl_down_spd_mb,
b.dsl_up_spd_mb,
b.fios_down_spd_mb,
b.fios_up_spd_mb,
b.prov_speed,
b.nbr_voice_lines,
b.tot_trouble_tkts,
b.trouble_tkts_rslvd,
b.trouble_tkts_not_rslvd,
b.tot_truck_rolls,
b.run_date,
b.snapshot_dt,
b.hsi_line_count
from xxx.COVID19_LTRS a
left joinxx.CAR_SERVICE b
ON a.acct_sk = b.acct_sk
AND snapshot_dt = DATE '2020-02-01'
THE CREATE TABLE:
CREATE TABLE xxx.aw_smbsuspend_dev_1 as
(Select
a.acct_sk,
a.product_id,
a.order_save_date,
a.comments,
a.b_name,
a.bill_addr,
a.bill_city,
a.bill_state,
a.bill_zip5,
a.bill_zip4,
a.marketing_primary_segment,
a.ord_creatd_dt,
b.voice_estbd_dt,
b.data_estbd_dt,
b.video_estbd_dt,
b.voice_svc_type_id,
b.voice_acct_status_id,
b.data_svc_type_id,
b.data_acct_status_id,
b.video_svc_type_id,
b.video_acct_status_id,
b.video_svc_type,
b.data_down_spd_mb,
b.data_up_spd_mb,
b.dsl_down_spd_mb,
b.dsl_up_spd_mb,
b.fios_down_spd_mb,
b.fios_up_spd_mb,
b.prov_speed,
b.nbr_voice_lines,
b.run_date,
b.snapshot_dt,
b.hsi_line_count
from xxx.COVID19_LTRS a
left join xx.CAR_SERVICE b
ON a.acct_sk = b.acct_sk
and b.snapshot_dt = DATE '2020-02-01') with data;
I have tried adding a group by clause and changing and to where...I am now just adding text because I'm being told to add more explanation but it is a very straightforward problem with a lot of columns.
I am just starting to work with openedge and I need to join information from two tables but I just need the first row from the second one.
Basically I need to do a typical SQL Cross Apply but in progress. I look in the documentation and the Statement FETCH FIRST 10 ROWS ONLY only in OpenEdge 11.
My query is:
SELECT * FROM la_of PUB.la_ofart ON la_of.empr_cod = la_ofart.empr_cod
AND la_of.Cod_Ordf = la_ofart.Cod_Ordf
AND la_of.Num_ordex = la_ofart.Num_ordex AND la_of.Num_partida = la_ofart.Num_partida
CROSS APPLY (
SELECT TOP 1 ofart.Cod_Ordf AS Cod_Ordf_ofart ,
ofart.Num_ordex AS Num_ordex_ofart
FROM la_ofart AS ofart
WHERE ofart.empr_cod = la_ofart.empr_cod
AND ofart.Num_partida = la_ofart.Num_partida
AND la_ofart.doc1_num = ofart.doc1_num
AND la_ofart.doc2_linha = ofart.doc2_linha
ORDER BY ofart.Cod_Ordf DESC) ofart
I am using SSMS to extract data from OE10 using an ODBC connector and querying to OE using OpenQuery.
Thanks for all help.
If I correctly understood your question, maybe you can use something like this. Maybe this isn't the best solution for your problem, but may suit your needs.
DEF BUFFER ofart FOR la_ofart.
DEF TEMP-TABLE tt-ofart NO-UNDO LIKE ofart
FIELD seq AS INT
INDEX ch-seq
seq.
DEF VAR i-count AS INT NO-UNDO.
EMPTY TEMP-TABLE tt-ofart.
blk:
FOR EACH la_ofart NO-LOCK,
EACH la_of NO-LOCK
WHERE la_of.empr_cod = la_ofart.empr_cod
AND la_of.Cod_Ordf = la_ofart.Cod_Ordf
AND la_of.Num_ordex = la_ofart.Num_ordex
AND la_of.Num_partida = la_ofart.Num_partida,
EACH ofart NO-LOCK
WHERE ofart.empr_cod = la_ofart.empr_cod
AND ofart.Num_partida = la_ofart.Num_partida
AND ofart.doc1_num = la_ofart.doc1_num
AND ofart.doc2_linha = la_ofart.doc2_linha
BREAK BY ofart.Cod_Ordf DESCENDING:
ASSIGN i-count = i-count + 1.
CREATE tt-ofart.
BUFFER-COPY ofart TO tt-ofart
ASSIGN ofart.seq = i-count.
IF i-count >= 10 THEN
LEAVE blk.
END.
FOR EACH tt-ofart USE-INDEX seq:
DISP tt-ofart WITH SCROLLABLE 1 COL 1 DOWN NO-ERROR.
END.
I would like to replace a value Test to Mess in Column A in a table T where the value is Var in Column B in the same table.
Please someone help me with the query as I'm new to Oracle.
This is very easy, try this:
UPDATE t
SET A = REPLACE(A, 'Test', 'Mess')
WHERE B = 'Var';
or if You want not replace, but full text update in A column, you can make like this :
UPDATE t
SET A = 'Mess'
WHERE B = 'Var' and A = 'Test';