Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
// format:
// statement row1
// statement row2
// ...
// statement rown
// <empty line>
sELect g.*, A.K from B, KLJ as A

select * from TABLE_A;

select * from TABLE_A

select * from TABLE_A LIMIT 34

select * from TABLE_A LIMIT ?

select * from TABLE_A LIMIT 34,?

select * from TABLE_A LIMIT ?,?

select * from TABLE_A LIMIT ? OFFSET 3

select * from TABLE_A LIMIT ? OFFSET ?

select * from TABLE_A LIMIT ALL OFFSET ?

select * from TABLE_A LIMIT ALL OFFSET 3

select * from TABLE_A OFFSET 3

select A,sdf,sch.tab.col from TABLE_A;

  	 select k, * from K as skldjfl where i=0

 select MAX(k+2), COUNT(*), MYCOL from K

SELECT * FROM TA2 LEFT JOIN O USING (col1, col2)
where D.OasSD = 'asdf' And (kj >= 4 OR l < 'sdf') 

seLECT 	my as KIO, lio aS
NE fRom TA2 LEFT OUter 		JOIN O as TA3
where D.OasSD = 'asdf' And (kj >= 4 OR l < 'sdf') 

select * from a 
INNer Join TAB_2 ON i.o = p.l whEre 'sdf'>'asdf' AND 
	(
	OL<>? 
			OR 
	L NOT IN (SELECT * FROM KJSD)
	)

select * from k where L IS NOT NUll;

(select sdf from sdfd) UNION (select * from k);

update mytab set jk=das, d=kasd+asd/d+3 where KL>= ds OR (k not in (SELECT K from KS));

insert into tabName VALUES ('sdgf', ?, ?)

insert into myschama.tabName2 (col1, col2, col3) VALUES ('sdgf', ?, ?)

delete from jk

delete from asdff where INI = 94 OR (ASD>9 AND (SELECT MAX(ID) from myt) > ?)

select  *  from  (  SELECT  intermediate.id  as  id  ,  intermediate.date  as  
date  FROM  (  SELECT  DISTINCT  ON  (  id  )  *  FROM  (  SELECT  
wct_workflows.workflow_id  as  id  ,  wct_transaction.date  as  date  FROM  
wct_audit_entry  ,  wct_transaction  ,  wct_workflows  WHERE  
(  wct_audit_entry.privilege  =  'W'  or  wct_audit_entry.privilege  =  
'C'  )  and  wct_audit_entry.outcome  =  't'  and  
wct_audit_entry.transaction_id  =  wct_transaction.transaction_id  and  
wct_transaction.user_id  = 164 and  wct_audit_entry.object_id  =  
wct_workflows.active_version_id)))

(select  *  from  (  SELECT  intermediate.id  as  id  ,  intermediate.date  as  
date  FROM  (  SELECT  DISTINCT   (  id  )  FROM  (  SELECT  
wct_workflows.workflow_id  as  id  ,  wct_transaction.date  as  date  FROM  
wct_audit_entry  ,  wct_transaction  ,  wct_workflows  WHERE  
(  wct_audit_entry.privilege  =  'W'  or  wct_audit_entry.privilege  =  
'C'  )  and  wct_audit_entry.outcome  =  't'  and  
wct_audit_entry.transaction_id  =  wct_transaction.transaction_id  and  
wct_transaction.user_id  = 164 and  wct_audit_entry.object_id  =  
wct_workflows.active_version_id))))  UNION ( SELECT  wct_workflows.workflow_id  as  
id  ,  wct_transaction.date  as  date  FROM  wct_audit_entry  ,  
wct_transaction  ,  wct_workflows  WHERE  (  wct_audit_entry.privilege  =  
'W'  or  wct_audit_entry.privilege  =  'C'  )  and  wct_audit_entry.outcome  
=  't'  and  wct_audit_entry.transaction_id  =  
wct_transaction.transaction_id  and  wct_transaction.user_id  = 164 and  
p= 'asd') 

select  *  from  (  SELECT  intermediate.id  as  id  ,  intermediate.date  as  
date  FROM  (  SELECT  DISTINCT   (  id  )   FROM  (  SELECT  
wct_workflows.workflow_id  as  id  ,  wct_transaction.date  as  date  FROM  
wct_audit_entry  ,  wct_transaction  ,  wct_workflows  WHERE  
(  wct_audit_entry.privilege  =  'W'  or  wct_audit_entry.privilege  =  
'C'  )  and  wct_audit_entry.outcome  =  't'  and  
wct_audit_entry.transaction_id  =  wct_transaction.transaction_id  and  
wct_transaction.user_id  = 164 and  wct_audit_entry.object_id  =  
wct_workflows.active_version_id ))) UNION  SELECT  wct_workflows.workflow_id  as  
id  ,  wct_transaction.date  as  date  FROM  wct_audit_entry  ,  
wct_transaction  ,  wct_workflows  WHERE  (  wct_audit_entry.privilege  =  
'W'  or  wct_audit_entry.privilege  =  'C'  )  and  wct_audit_entry.outcome  
=  't'  and  wct_audit_entry.transaction_id  =  
wct_transaction.transaction_id  and  wct_transaction.user_id  = 164 and  
afdf=  (  select  wct_audit_entry.object_id  from  wct_audit_entry  ,  
wct_workflow_archive  where  wct_audit_entry.object_id  =  
wct_workflow_archive.archive_id  and  wct_workflows.workflow_id  =  
wct_workflow_archive.workflow_id  ) 
UNION  SELECT  wct_workflows.workflow_id  
as  id  ,  wct_transaction.date  as  date  FROM  wct_audit_entry  ,  
wct_transaction  ,  wct_workflows  WHERE  (  wct_audit_entry.privilege  =  
'W'  OR  wct_audit_entry.privilege  =  'E'  OR  wct_audit_entry.privilege  =  
'A'  )  and  wct_audit_entry.outcome  =  't'  and  
wct_audit_entry.transaction_id  =  wct_transaction.transaction_id  and  
wct_transaction.user_id  = 164 and  wct_audit_entry.object_id  =  
wct_workflows.workflow_id    UNION SELECT * FROM interm2  ,  wct_workflow_docs  WHERE  
interm2.id  =  wct_workflow_docs.document_id  ORDER BY  id  ,  date  DESC  

replace df set ki='oasdf', dsd=asd+dd

(select sdf from sdfd) UNION (select * from k) ORDER BY 1,2;

(select sdf from sdfd) UNION (select * from k) ORDER BY 1,asd.sd ;

(select sdf from sdfd) UNION (select * from k) UNION (select * from k2) LIMIT 0,2;

select sdf from sdfd UNION select * from k join j on k.p = asdf.f;

select  *  from  (  select  persistence_dynamic_ot.pdl_id  , 
acs_objects.default_domain_class  as  attribute0  , 
acs_objects.object_type  as  attribute1  ,  acs_objects.display_name 
as  attribute2  ,  persistence_dynamic_ot.dynamic_object_type  as 
attribute3  ,  persistence_dynamic_ot.pdl_file  as  attribute4  from 
persistence_dynamic_ot  ,  acs_objects  where 
persistence_dynamic_ot.pdl_id  =  acs_objects.object_id  )

SELECT * FROM table1 WHERE column1 > ALL (SELECT column2 FROM table1)

INSERT INTO mytable (col1, col2, col3) SELECT * FROM mytable2

insert into foo ( x )  select a from b 

select (case when a > 0 then b + a else 0 end) p from mytable

SELECT BTI.*, BTI_PREDECESSOR.objid AS predecessor_objid, BTI_PREDECESSOR.item_id
AS predecessor_item_id, BTIT_PREDECESSOR.bt_item_type_key AS predecessor_type_key,
CAT.catalog_key, S.objid AS state_objid, S.state_key, S.is_init_state,
S.is_final_state, mlS.name AS state, BTIT.bt_item_type_key, BTP.bt_processor_key,
mlBTP.name AS bt_processor_name , CU.objid AS cust_user_objid , CU.title AS
cust_user_title , CU.firstname AS cust_user_firstname , CU.lastname AS
cust_user_lastname , CU.salutation2pv AS cust_user_salutation2pv , PV_CU.name_option
AS cust_user_salutation , A_CU.email AS cust_user_email , '' AS use_option_field,
'' AS use_readerlist , BTI_QUOTATION.quotation_type2pv , BTI_QUOTATION.is_mandatory
AS quotation_is_mandatory , BTI_QUOTATION.is_multiple AS quotation_is_multiple
, BTI_QUOTATION.expiration_datetime AS quotation_expiration_datetime ,
BTI_QUOTATION.hint_internal AS quotation_hint_internal , BTI_QUOTATION.hint_external
AS quotation_hint_external , BTI_QUOTATION.filter_value AS quotation_filter_value
, BTI_QUOTATION.email_cc AS quotation_email_cc , BTI_QUOTATION.notification1_datetime
AS notification1_datetime , BTI_QUOTATION.notification2_datetime AS
notification2_datetime , BTI_RFQ.filter_value AS request_for_quotation_filter_value
FROM tBusinessTransactionItem BTI LEFT OUTER JOIN tBusinessTransactionItem_Quotation
BTI_QUOTATION ON BTI_QUOTATION.this2business_transaction_item = BTI.objid LEFT
OUTER JOIN tBusinessTransactionItem_RequestForQuotation BTI_RFQ ON
BTI_RFQ.this2business_transaction_item = BTI.objid LEFT OUTER JOIN
tBusinessTransactionItem BTI_PREDECESSOR ON BTI_PREDECESSOR.objid
= BTI.predecessor2bt_item, tBusinessTransactionItemType BTIT_PREDECESSOR
, tBusinessTransactionItemType BTIT, tBusinessTransactionProcessor BTP,
mltBusinessTransactionProcessor mlBTP, tLanguagePriority LP_BTP, tState S, mltState
mlS, tLanguagePriority LP_S, tCatalog CAT
, tBusinessTransactionItem2BusinessTransaction BTI2BT ,
tBusinessTransactionItem2SessionCart BTI2SC , tSessionCart SC , tCustUser CU_MASTER
, tCustUser CU , tPopValue PV_CU , tAddress A_CU , tAddress2CustUser A2CU WHERE
BTI.objid <> -1 AND BTI_PREDECESSOR.this2bt_item_type = BTIT_PREDECESSOR.objid
AND BTI.this2bt_item_type = BTIT.objid AND BTI.this2bt_processor = BTP.objid
AND mlBTP.this2master = BTP.objid AND mlBTP.this2language = LP_BTP.item2language
AND LP_BTP.master2language = 0 AND LP_BTP.this2shop = 0 AND LP_BTP.priority
= (SELECT MIN(LP_BTP2.priority) FROM tLanguagePriority LP_BTP2,
mltBusinessTransactionProcessor mlBTP2 WHERE LP_BTP2.master2language = 0 AND
LP_BTP2.this2shop = 0 AND LP_BTP2.item2language = mlBTP2.this2language
AND mlBTP2.this2master = BTP.objid ) AND BTI.this2catalog = CAT.objid AND S.objid
= BTI.bt_item2state AND mlS.this2master = S.objid AND mlS.this2language
= LP_S.item2language AND LP_S.master2language = 0 AND LP_S.this2shop = 0 AND
LP_S.priority = (SELECT MIN(LP_S2.priority) FROM tLanguagePriority LP_S2, mltState
mlS2 WHERE LP_S2.master2language = 0 AND LP_S2.this2shop = 0 AND LP_S2.item2language
= mlS2.this2language AND mlS2.this2master = S.objid ) AND BTI.objid
= BTI2BT.this2business_transaction_item AND CU_MASTER.objid = 1101 AND
CU.this2customer = CU_MASTER.this2customer AND SC.this2custuser = CU.objid AND
BTI.objid = BTI2SC.this2business_transaction_item AND BTI.bt_item2state = 6664
AND BTI2SC.is_master_cart_item = 1 AND BTI2SC.this2session_cart = SC.objid AND
EXISTS (SELECT NULL FROM tBusinessTransaction BT, tBusinessTransactionType BTT
WHERE BT.objid = BTI2BT.this2business_transaction AND BTT.objid = BT.this2bt_type
AND BTT.business_transaction_type_key = 'order:master_cart') AND PV_CU.objid
= CU.salutation2pv AND A2CU.this2custuser = CU.objid AND A2CU.is_billing_default
= 1 AND A2CU.this2address = A_CU.objid ORDER BY BTI.dbobj_create_datetime DESC

WITH 
DINFO (DEPTNO, AVGSALARY, EMPCOUNT) AS 
(SELECT OTHERS.WORKDEPT, AVG(OTHERS.SALARY), COUNT(*) 
FROM EMPLOYEE OTHERS 
GROUP BY OTHERS.WORKDEPT 
), 
DINFOMAX AS 
(SELECT MAX(AVGSALARY) AS AVGMAX FROM DINFO) 
SELECT THIS_EMP.EMPNO, THIS_EMP.SALARY, 
DINFO.AVGSALARY, DINFO.EMPCOUNT, DINFOMAX.AVGMAX 
FROM EMPLOYEE THIS_EMP, DINFO, DINFOMAX 
WHERE THIS_EMP.JOB = 'SALESREP' 
AND THIS_EMP.WORKDEPT = DINFO.DEPTNO  

select * from Person where deptname='it' AND NOT (age=24) 
New to GrepCode? Check out our FAQ X