You must Sign In to post a response.
  • Category: SQL Server

    How to use 2 select query in single query


    I have a select query with group by and where conditions.

    select Date,Name,count(*)Total from TableName where dt=getdate() group by Date,Name

    Date Name Total

    Aug12 abc 150

    Now Im trying to bring out another select query with same where conditions but one condition extra

    Date Name Total Price

    Aug12 abc 150 45

    select Date,Name,count(*)Total,(select Price1 from TableName where dt=getdate() and status=true ) from TableName dt=getdate() group by Date,Name

    Instead of this subquery any way to use join
  • #770093
    Hi Lily,

    Price1 column is there in the same table or different table?

    Either you should use UNION or join but still, I'm not clear with your question so i can't suggest you anything. Your question is confusing.

    Share your query in detail so I can help you.

    Thank you.

    Nirav Lalan
    DNS Gold Member
    "If you can dream it, you can do it."

  • #770410
    You could carry out the following:
    name, games, goals
    FROM tblMadrid WHERE name = 'ronaldo')
    name, games, goals
    FROM tblBarcelona WHERE name = 'Mohni')
    ORDER BY goals;

  • Sign In to post your comments