Skip to content
Advertisement

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 than the post id=3 if not

Maintain order when using SQLite WHERE-clause and IN operator

Consider the following tbl: For reference, tbl looks like this: When issuing the following statement, the result will be ordered according to ID. However, I need the ordering to adhere to the order of the passed list of values. Here’s what I am looking for: Answer You can create a CTE that returns 2 columns: the values that you search

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’t work. How

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 <> instructo… Any fix? Answer Please try this: Instead of where you need to use on

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

Advertisement