|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 113568901 于 2013-5-8 10:10 编辑
excel中A列是许多城市的名称,现在我需要利用sql语句自动判断出城市所在的省份,详见附件。
附件中B列是我用公式达到的效果,但是如何用sql语句实现呢?求各位大大帮助。用IIF+instr一层层嵌套理论上是可以实现的,但相当麻烦,所以有没有类似我的公式的方法来实现呢?
公式如下:
=IF(COUNT(FIND({"北京"},A2)),"北京市",IF(COUNT(FIND({"天津"},A2)),"天津市",IF(COUNT(FIND({"上海"},A2)),"上海市",IF(COUNT(FIND({"重庆"},A2)),"重庆市",IF(COUNT(FIND({"合肥","毫州","芜湖","马鞍山","池州","黄山","滁州","安庆","淮南","淮北","蚌埠","巢湖","宿州","宣城","六安","阜阳","铜陵","明光","天长","宁国","界首","桐城"},A2)),"安徽省",IF(COUNT(FIND({"福州","厦门","泉州","漳州","南平","三明","龙岩","莆田","宁德","建瓯","武夷山","长乐","福清","晋江","南安","福安","龙海","邵武","石狮","福鼎","建阳","漳平","永安"},A2)),"福建省",""))))))
附件.rar
(10.1 KB, 下载次数: 15)
|
|