---
title: "日志归档SQL写法"
author: "cetusz"
date: "2009-11-24T15:07:00Z"
tags: []
categories: ["数据库"]
slug: "sql"
draft: false
lastmod: "2010-10-18T09:28:40Z"
id: 787132
url: "https://cetus.iteye.com/blog/787132"
---

"select year(pubdate),month(pubdate),count(id) from News Group by year(pubdate),month(pubdate) order by year(pubdate) desc,month(pubdate) desc" 

 

access不支持when case end sql语法 但有iif()函数可以代替

如iif(test=1,'me',iif(test=2,'you','other')

相当于

case test when 1 then 'me' when 2 then 'you' else 'other' end from table