Skip to content

Tag: where-clause

PostgreSQL select record with multiple condition

I am trying to select the record but not getting the record I wanted. here is my sqlfiddle http://sqlfiddle.com/#!17/5296a/1 so when I selects the record using below query it gives me result with the title DDDDD. it should give me GGGGGGGG. I wanted to check if there is any record with author_id=3 and greater…

How use case statement alias in where clause

I’m trying to use a case statement and the results to in an alias, but I need to use the alias in my where clause and this doesn’t seem to be working. How do I use the alias (isPrimary below) in my where clause. See comment where I’m trying to use isPrimary in my where clause, which doesn&#8…

Create SQL statement with mulitple AND

I have a problem with creating right SQL request. This is my table: I would like to display all items that: -Are in warehouse A in number less than 2 -Are in watehouse B in number grater than 0 At the same time. I would expect item1 will be displayed. My code so far is: I know that warehouse =

Syntax error while using WHERE clause in PostgreSQL

I’m trying to run some queries related to the University database in PostgreSQL. To find students advised by instructors from different departments, I used- However im getting the following error: ERROR: syntax error at or near “where” LINE 3: student join instructor where student.dept_name …

SQL an ID in one group and an id from another

I have a request where I need a count where a participant completed an activity under one id (the gateway to completing other things) and then an id in a list of other ids. Right now, this code is only coming back with the the a count of the one id but not saying that one id complete + the