---
title: "where case when..."
type: "forum-thread"
url: "https://www.webforum.nu/amne/databaser-sql/114587-where-case-when"
topic: "Databaser & SQL"
topic_url: "https://www.webforum.nu/amne/databaser-sql"
author: "doggelito"
published: "2004-10-28T08:21:13.000Z"
updated: "2004-10-28T13:12:48.000Z"
replies: 2
views: 238
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/databaser-sql/114587-where-case-when"
---

# where case when...

## #1 — doggelito, 2004-10-28T08:21Z

får inte till denna:
om @Level3 = 0 då får inte ParentIdno vara lika som SubIDno.

felkod: Incorrect syntax near '\<'.

```
ALTER   Procedure upCategory
	@CategoryId int, 
	@Level3 int

As
	Set NoCount On
	
	Select a.IDno, a.ParentIDno, a.TopIDno, a.SubIDno, a.Fullname, a.Enabled, a.CreateDate
	From Category a
	Where Case When @Level3=0 Then ParentIDno <> SubIDno End
	Order By a.TopIDno, a.SubIDno, a.ParentIDno, a.Fullname
```

Permalänk: https://www.webforum.nu/p/114587

## #2 — LarsG, 2004-10-28T13:08Z

```
Where (@Level3=0 and ParentIDno <> SubIDno)
or @level3 <> 0
```

Permalänk: https://www.webforum.nu/p/1469799

## #3 — doggelito, 2004-10-28T13:12Z

Tiptop! :bire

Permalänk: https://www.webforum.nu/p/1469803

---

Tråden på webben: https://www.webforum.nu/amne/databaser-sql/114587-where-case-when
