Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8548871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:35:51+00:00 2026-06-11T13:35:51+00:00

I have this script: SELECT ‘pro’ as descript, COUNT(*) as cnt FROM Trade.TradesMen where

  • 0

I have this script:

 SELECT 'pro' as descript, COUNT(*) as cnt FROM Trade.TradesMen where TradesManAccountType_Value = 2 AND HasTradeListing = 1
 UNION ALL

 SELECT 'std' as descript, COUNT(*) as cnt FROM Trade.TradesMen tm
 INNER JOIN Membership.Members m ON m.MemberId = tm.MemberId
 INNER JOIN aspnet_Membership am ON am.UserId = m.AspNetUserId
 WHERE tm.TradesManAccountType_Value = 1 AND tm.HasTradeListing = 1 AND am.IsApproved = 1

 UNION ALL

 SELECT 'listed' as descript, COUNT(*) as cnt FROM Trade.TradesMen where HasTradeListing = 1

 UNION ALL

 SELECT 'all' as descript, COUNT(*) as cnt FROM Trade.TradesMen
 insert into Admin.VersionHistory values(4,cnt,CURRENT_TIMESTAMP) //is NOT correct

this produces:

 1     pro          32549
 2     std          13096
 3     listed   230547
 4     all          231638

I want to add the above as rows in my table: Admin.VersionHistory which has columns VersionHistory type int auto-increment and is the ID, Version which is of type varchar(50) and a datatime stamp

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:35:53+00:00Added an answer on June 11, 2026 at 1:35 pm

    (updated with new info from OP)
    From the top of my head, it would look something like this.

    INSERT INTO Admin.VersionHistory (Version, NumberOf, DateAndTime)
    SELECT descript, CAST(cnt AS VARCHAR), SYSDATE
    FROM
    (
    SELECT 'pro' as descript, COUNT(*) as cnt FROM Trade.TradesMen where TradesManAccountType_Value = 2 AND HasTradeListing = 1
    
    UNION ALL
    
    SELECT 'std' as descript, COUNT(*) as cnt FROM Trade.TradesMen tm
    INNER JOIN Membership.Members m ON m.MemberId = tm.MemberId
    INNER JOIN aspnet_Membership am ON am.UserId = m.AspNetUserId
    WHERE tm.TradesManAccountType_Value = 1 AND tm.HasTradeListing = 1 AND am.IsApproved = 1
    
    UNION ALL
    
    SELECT 'listed' as descript, COUNT(*) as cnt FROM Trade.TradesMen where HasTradeListing = 1
    
    UNION ALL
    
    SELECT 'all' as descript, COUNT(*) as cnt FROM Trade.TradesMen
    ) ;
    

    This is assuming the VersionHistoryIdcolumn is automatically seeded by the database. With each insert, an ID number will be automatically inserted.

    Not sure what you want to achieve with the CURRENT_TIMESTAMP column though. I put SYSDATE as a timestamp.

    The NumberOf column contains the count data. Name it as you see fit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this SQL script i my app: select my_seq.nextval from dual connect by
I have this script:- SELECT TOP 1 column_01, COUNT(column_01) OVER(), (SELECT TOP 1 COUNT(column_02)
I have this script: select name,create_date,modify_date from sys.procedures order by modify_date desc I can
I have this script: <? $query = mysql_query(SELECT * FROM azzdk) or die(mysql_error()); $row
i have this script <select> <option value=1>one<img src=star.gif height=15 width=15></img> </option> </select> but it
So i have this script: <?php $query = mysql_query( SELECT meetup AS text, id
I have this jQuery script that works fine: $(select).change(function () { var finalPrice =
Okay so I have this web site search script and I'm trying to count
I have this script to output everything from table called Articles. If I load
:-) I have this script, which find a users position taken from the number

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.