with 的用法

with 的用法

1. 独立主格,表示伴随,所以必须修饰主谓宾结构,而非主系表结构。 独立主格三种形式: 1)一般形式(独立部分与主句部分无太多关联)n.+n.,n.+V-ed/v-ing,n.+介词短语/形容词短语

2)with形式(与主句主语有紧密的逻辑关系):with+宾语+宾补,如:with+n.+v-ed/v-ing/介词短语/形容词短语 3)each形式(必须前面有复数名词): each+v-ed/v-ing,each+介词短语/形容词短语,each+n.+介词短语

*:with型独立主格在GMAT中常常被判累赘。

With引导独立主格结构有修饰歧义--放在中间可修饰前者也可修饰后者。 Eg. 关于夹心修饰 (by aeoluseros):

所以歧义修饰,是因为引发了不同的理解,而并不是语法上是否会有不同的修饰,所谓夹心修饰也是这个原则。很多人对“夹心修饰”都有过一个误解,认为S, v-ing, V. + O.结构中,v-ing既可以往前修饰S,也可以往后修饰V就是夹心,而实际上夹心并不是“可以往前修饰S,也可以往后修饰V” 。在S, v-ing, V. + O.这样的表达中,v-ing约定俗成只伴随修饰动词,见下例:

prep 2-104 The yield per acre of coffee berries varies enormously, because a single tree, berries to make between one and twelve pounds of dried beans a year. 这个句子里depending不能改为dependent,因为depending和dependent的区别在于,前者伴随修饰谓语动词is able to produce,后者则是修饰名词single tree,会造成逻辑上不对 —— “一棵树依靠它的size”。

with独立主格结构:

由“with +宾语+宾补”构成的复合结构,在句中可作状语,表示伴随。这一结构中的宾语补足语可由现在分词、过去分词、形容词、副词或介词短语等来充当: Visitors to the park have often looked into the leafy canopy and seen monkeys sleeping on the branches, with arms and legs hanging like socks on a clothesline.

Q16: PP73.

A. With no natural predators and expanses of green suburban neighborhoods that allow no hunting, wildlife officials estimate the New Jersey deer population to have

B. With no natural predators and with expanses of green suburban neighborhoods that do not

allow hunting, wildlife officials' estimate of the deer population in New Jersey has

C. With no natural predators and with expanses of green suburban neighborhoods where

there is no hunting, the deer population in New Jersey, wildlife officials estimate, has

D. Without natural predators and no hunting allowed in expanse of green suburban

neighborhoods, New Jersey has a deer population that wildlife officials estimate to have E. Without natural predators and with expanses of green neighborhoods where there is no

hunting, wildlife officials in New Jersey estimate a deer population that has

170. (GWD21-Q12)

Birds known as honeyguides exhibit a unique pattern of behavior: the bird leads another animal, such as a honey-badger or a human, to a bees’ nest wax and bee larvae.

A. with their chattering when they fly

B. with chattering and its flying

C. by chattering as it flies

D. by chattering and its flying

E. by chattering as they are flying

题目释义:the bird leads sth , , to a bees’ nest by chattering as it flies

主语是the bird,谓语动词lead sth to some place, by+分词结构为方式状语,as引导时间状语从句。

考点:

指代一致,逻辑表达

1. with和by的区别:

(1) 做某事时通过什么方法或手段用by:do something by (doing) something。

(2) 表示使用有形工具时,通常用with来表示:write with a pen, see with naked eyes, strike with a hammar

(3) 作”用”讲时,by和with的区别在于:with表示行为动作的工具,后面的名词一般

要有冠词;by表示动作的手段,后面的名词一律不用冠词。

2. as和when引导的时间状语含义不同:

(1) as表示"当……时""一面……一面","随着"。具体用法如下:

1) 表示"当……时"、"和……同时"。常指从句的动作未结束,主句中的动

作就已发生。从句中多用表示动作的动词,而不用be动词或表示感觉、

理解、知道这类动词。

e.g. As he stood there, he saw two men enter the bar.

She dropped the glass as she stood up.

2) 用于平行的动作中,表示"一面……一面……"。常指一个主语同时进行

两个动作。

e.g. The students took notes as they listened.

3) 用于平行发展的结构中,表示"随着……"。常指一个行为是另一个行为

的结果,或一种状态随另一种状态变化。句中的动词多表示状态的发

展变化。

e.g. As the wind rose the noise increased.

As it grew darker it became colder.

As he grew older he became more confident.

(2) when表示“当……的时候”。从句中既可用延续性动词,又可用非延续性动词,

这些动词既可以表示动作,又可表示状态。从句中的动作既可和主句的动作同时发生,又可在主句的动作之前或之后发生。

When I came into the room, I found him lying there asleep. <表示动作,主从动作同时发生>

Mary was having dinner when I saw her. <表示动作,主从动作同时发生>

When you meet a word you don't know, consult the dictionary. <表示动作,从句动作在前>

She was beautiful when she was a girl. <表示状态>

*:所以,when引导的仅仅是最单纯的时间状语,在要表示伴随含义的时候,用as比用when更为合适。

选项分析:

(A) they以及their和前面未划线的the bird指代不一致,应为单数it;通过某某方法要用

by,而不是with;when引导的时间状语从句没有伴随的含义,应该用as更好。

(B) 通过某某方式要用by,而不是with;chattering and its flying不平行;时间状语改为

平行结构少了伴随、同时发生的含义。

(C) Correct,这里as是“一面飞一面喋喋”,上面谈到的as引导时间状语时的第2中用法。

(D) chattering and its flying不平行;时间状语改为平行结构少了伴随、同时发生的含

义。

(E) the bird应为单数,指代词要用it。

175. (GWD-9-Q3)

across a wide region at night and on weekends, when numerous wireless companies provide unlimited airtime for a relatively small monthly fee.

A. Because of wireless service costs plummeting in the last year, and as mobile

phones are increasingly common, many people

B. As the cost of wireless service plummeted in the last year and as mobile phones

became increasingly common, many people

C. In the last year, with the cost of wireless service plummeting, and mobile phones

have become increasingly common, there are many people

D. With the cost of wireless service plummeting in the last year and mobile phones

becoming increasingly common, many people are

E. While the cost of wireless service has plummeted in the last year and mobile

phones are increasingly common, many people are

题目释义:With …., many people are now using…..,when

With引导独立主格结构作原因状语,主语many people,谓语use的进行时

态,when引导时间状语修饰谓语动词。

考点:

题目释义

1)在主从复杂句子中要注意主句和从句的主谓结构是否齐全,常见的错误选项是缺少主句谓语。

选项分析:

(A) and前后的分句结构都不完整;because of和as不平行对称;because of后面核心词

只有costs,无法表达出完整含义,awkward。

(B) 缺少主谓成分,句子结构不完整;in the last year通常与现在完成时搭配;未划线

部分的provide用的是一般现在时,则as mobile phones became increasingly common中,became

(C) and前后成分不平行;and后面句子run-on的错误;此处there be句型不及主谓结构

更有效,wordy;in the last year提前,从仅修饰the cost of wireless service plummeted变为修饰整句话,造成逻辑错误

(D) Correct;with可以表示原因,与as含义相似(见补充说明);注意become和

increasingly并不重复,increasingly只是表达了more and more的含义,become与more常搭配使用

(E) while引导的从句要与主句发生在同一时间,可是wireless service has plummeted与

主句不是同一时间发生的,用while错误,而且用as表示原因或伴随更为合适 补充说明:

1. with是有"因为"的意思:(the following explanations are from Longman dictionary)

释义: because of a situation that exists:

With John away there's more room in the house.

短语: with something doing something

I can't do my homework with all this noise going on.

2. 注意in last与in the last的区别:

e.g. : Did you see the game on TV last night? 昨天晚上

e.g. : Interest in golf has grown rapidly in the last ten years. 最近十年

再如大全242. Despite the recent election of a woman to the office of prime minister, (A) is little changed from how it was

(B) is a little change from how it was

(C) has changed little

(D) has changed little from how it has been

(E) is little changed from the way it was

Key:C。last 此处意思为"最近的"而不是"上一个",否则就不必用the.

 

第二篇:sql中with_as的用法

SQL中使用WITH AS提高性能-使用公用表表达式(CTE)简化嵌套SQL

一.WITH AS的含义

WITH AS短语,也叫做子查询部分(subquery factoring),可以让你做很多事情,定义一个SQL片断,该SQL片断会被整个SQL语句所用到。有的时候,是为了让SQL语句的可读性更高些,也有可能是在UNION ALL的不同部分,作为提供数据的部分。

特别对于UNION ALL比较有用。因为UNION ALL的每个部分可能相同,但是如果每个部分都去执行一遍的话,则成本太高,所以可以使用WITH AS短语,则只要执行一遍即可。如果WITH AS短语所定义的表名被调用两次以上,则优化器会自动将WITH AS短语所获取的数据放入一个TEMP表里,如果只是被调用一次,则不会。而提示materialize则是强制将WITH AS短语里的数据放入一个全局临时表里。很多查询通过这种方法都可以提高速度。

二.使用方法

先看下面一个嵌套的查询语句:

select * from person.StateProvince where CountryRegionCode in

(select CountryRegionCode from person.CountryRegion where Name like 'C%')

上面的查询语句使用了一个子查询。虽然这条SQL语句并不复杂,但如果嵌套的层次过多,会使SQL语句非常难以阅读和维护。因此,也可以使用表变量的方式来解决这个问题,SQL语句如下: declare @t table(CountryRegionCode nvarchar(3))

insert into @t(CountryRegionCode) (select CountryRegionCode from person.CountryRegion where Name like 'C%')

select * from person.StateProvince where CountryRegionCode

in (select * from @t)

虽然上面的SQL语句要比第一种方式更复杂,但却将子查询放在了表变量@t中,这样做将使SQL语句更容易维护,但又会带来另一个问题,就是性能的损失。由于表变量实际上使用了临时表,从而增加了额外的I/O开销,因此,表变量的方式并不太适合数据量大且频繁查询的情况。为此,在SQL Server 20xx中提供了另外一种解决方案,这就是公用表表达式(CTE),使用CTE,可以使SQL语句的可维护性,同时,CTE要比表变量的效率高得多。

下面是CTE的语法:

[ WITH <common_table_expression> [ ,n ] ]

<common_table_expression>::=

expression_name [ ( column_name [ ,n ] ) ]

AS

( CTE_query_definition )

现在使用CTE来解决上面的问题,SQL语句如下:

With cr as(

select CountryRegionCode from person.CountryRegion where Name like 'C%'

)

select * from person.StateProvince where CountryRegionCode in (select * from cr)

其中cr是一个公用表表达式,该表达式在使用上与表变量类似,只是SQL Server 20xx在处理公用表表达式的方式上有所不同。

在使用CTE时应注意如下几点:

1. CTE后面必须直接跟使用CTE的SQL语句(如select、insert、update等),否则,CTE将失效。如下面的SQL语句将无法正常使用CTE:

with cr as

(

select CountryRegionCode from person.CountryRegion where Name like 'C%'

)

select * from person.CountryRegion -- 应将这条SQL语句去掉

-- 使用CTE的SQL语句应紧跟在相关的CTE后面 --

select * from person.StateProvince where CountryRegionCode in (select * from cr)

2. CTE后面也可以跟其他的CTE,但只能使用一个with,多个CTE中间用逗号(,)分隔,如下面的SQL语句所示:

With cte1 as(

select * from table1 where name like 'abc%'

),

cte2 as(

select * from table2 where id > 20

),

cte3 as(

select * from table3 where price < 100

)

select a.* from cte1 a, cte2 b, cte3 c where a.id = b.id and a.id = c.id

3. 如果CTE的表达式名称与某个数据表或视图重名,则紧跟在该CTE后面的SQL语句使用的仍然是CTE,当然,后面的SQL语句使用的就是数据表或视图了,如下面的SQL语句所示:

-- table1是一个实际存在的表

With table1 as

(

select * from persons where age < 30

)

select * from table1 -- 使用了名为table1的公共表表达式

select * from table1 -- 使用了名为table1的数据表

4. CTE 可以引用自身,也可以引用在同一 WITH 子句中预先定义的 CTE。不允许前向引用。

5. 不能在 CTE_query_definition 中使用以下子句:

(1)COMPUTE 或 COMPUTE BY

(2)ORDER BY(除非指定了 TOP 子句)

(3)INTO

(4)带有查询提示的 OPTION 子句

(5)FOR XML

(6)FOR BROWSE

6. 如果将 CTE 用在属于批处理的一部分的语句中,那么在它之前的语句必须以分号结尾,如下面的SQL所示:

declare @s nvarchar(3)

set @s = 'C%'

; -- 必须加分号

with t_tree as

(

select CountryRegionCode from person.CountryRegion where Name like @s

)

select * from person.StateProvince where CountryRegionCode in (select * from t_tree)

CTE除了可以简化嵌套SQL语句外,还可以进行递归调用,关于这一部分的内容将在下一篇文章中介绍。

相关推荐